Results 1 to 7 of 7

Thread: if filter text equals "*" insert block "*"

  1. #1
    I could stop if I wanted to
    Join Date
    2007-05
    Location
    Brookfield WI
    Posts
    331
    Login to Give a bone
    0

    Default if filter text equals "*" insert block "*"

    Trying to use a filter to search titleblock for specific state(s), if state A insert block for state A and so on

    not sure if this helps but wildcard equals city.

    example filter:

    Code:
    (setq ssvi (ssget "x" '((0 . "TEXT") (1 . "*, VIRGINIA"))))
    (setq sswi (ssget "x" '((0 . "TEXT") (1 . "*, WISCONSIN"))))
    how do I get it to insert block after filter finds text?

  2. #2
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Smile Re: if filter text equals "*" insert block "*"

    Quote Originally Posted by d_m_hopper View Post
    Trying to use a filter to search titleblock for specific state(s), if state A insert block for state A and so on

    not sure if this helps but wildcard equals city.

    example filter:

    Code:
    (setq ssvi (ssget "x" '((0 . "TEXT") (1 . "*, VIRGINIA"))))
    (setq sswi (ssget "x" '((0 . "TEXT") (1 . "*, WISCONSIN"))))
    how do I get it to insert block after filter finds text?
    You can check to see if you have anything in your selection set. If you do, then you can do an insert. Something like:
    Code:
    (if ssvi
      (progn
        ;;insert block
      )
    );;end if ssvi (Virginia)
    (if sswi
      (progn
        ;;insert block
      )
    );;end if sswi (Wisconsin)
    These are simply testing if a selection set was made. If there are no text objects that match your criteria, then the selection set will be nil.

    However, alternate code (depending on your needs) could be written as this:
    Code:
    (cond
      (ssvi
        ;;insert block
      );;end ssvi (Virginia)
      (sswi
        ;;insert block
      );;end sswi (Wisconsin)
    )
    The difference is this code will stop and execute the first match while the other method using IF for each would execute for each match. I assume you would only need it to execute once (for the first match) as you state you are retrieving the information from your titleblock; of which I assume you only have one project per file. If this is the case, the second method shown (with the COND) would be a better choice.

    On another note, you may want to add an asterisk (*) to the end of the text to be searched as well. This would ensure that if the name of the state was located in the middle of the text, it will still be found. Currently, it will only match those that have the name of the state at the end. So, even something such as "RICHMOND, VIRGINIA " would match if your search was "*, VIRGINIA*" (notice the extra spaces). With your original ("*, VIRGINIA"), it would be missed. Just want to make sure you are aware of this

  3. #3
    I could stop if I wanted to
    Join Date
    2007-05
    Location
    Brookfield WI
    Posts
    331
    Login to Give a bone
    0

    Default Re: if filter text equals "*" insert block "*"

    Thanks, one for the "*" tip at the end of the text I am filtering for, that will help when filtering for words in foreign countries where the text string ends in the country name. Example we use Toronto, Ontario, Canada

    Secondly a selection set was created, I tested for that, what I was doing was saying if VIRGINIA insert block, not if ssvi insert block.

  4. #4
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Smile Re: if filter text equals "*" insert block "*"

    Quote Originally Posted by d_m_hopper View Post
    Thanks, one for the "*" tip at the end of the text I am filtering for, that will help when filtering for words in foreign countries where the text string ends in the country name. Example we use Toronto, Ontario, Canada

    Secondly a selection set was created, I tested for that, what I was doing was saying if VIRGINIA insert block, not if ssvi insert block.
    No problem on the "*" tip, I've had tests fail for the same reason and just wanted to pass it on

  5. #5
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,197
    Login to Give a bone
    0

    Default Re: if filter text equals "*" insert block "*"

    Quote Originally Posted by d_m_hopper View Post
    Trying to use a filter to search titleblock for specific state(s), if state A insert block for state A and so on

    not sure if this helps but wildcard equals city.

    example filter:

    Code:
    (setq ssvi (ssget "x" '((0 . "TEXT") (1 . "*, VIRGINIA"))))
    (setq sswi (ssget "x" '((0 . "TEXT") (1 . "*, WISCONSIN"))))
    how do I get it to insert block after filter finds text?
    your current search will put all text in the selection set with the *. If you want to search for the City, Virginia, you may have to put a ` before the comma, so it is read literally as a comma, not as a divide between two text filters. If you could post more of your code, it would be a little easier to tell you how to insert the block. I would assume that you would want to use a condition
    Code:
    (cond
    (
    (setq ssvi (ssget "x" '((0 . "TEXT") (1 . "*`, VIRGINIA"))))
    (command "insert" "whatever the rest of the prompts are")
    )
    (
    (setq sswi (ssget "x" '((0 . "TEXT") (1 . "*, WISCONSIN"))))
    (command "insert" "whatever the rest of the prompts are")
    )
    )

  6. #6
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: if filter text equals "*" insert block "*"

    Yep, that's just it, the comma is used to separate different filter criteria. For example "*test1,*test2" will filter everything ending in either test1 or test2. The way of getting round this is (as ccowgill states) prefixing any control character with a reverse qoute (`). From the developer's help these are the control codes used in wcmatch (which are the same as that used in ssget:
    Code:
    Wild-card characters
    Character           Definition
    #(pound)            Matches any single numeric digit.
    @(at)               Matches any single alphabetic character.
    .(period)           Matches any single nonalphanumeric character.
    *(asterisk)         Matches any character sequence, including an empty one, and it can be used anywhere in the search pattern: at the beginning, middle, or end.
    ?(question mark)    Matches any single character.
    ~(tilde)            If it is the first character in the pattern, it matches anything except the pattern.
    [...]               Matches any one of the characters enclosed.
    [~...]              Matches any single character not enclosed.
    -(hyphen)           Used inside brackets to specify a range for a single character.
    ,(comma)            Separates two patterns.
    `(reverse quote)    Escapes special characters (reads next character literally).

  7. #7
    I could stop if I wanted to
    Join Date
    2007-05
    Location
    Brookfield WI
    Posts
    331
    Login to Give a bone
    0

    Default Re: if filter text equals "*" insert block "*"

    Quote Originally Posted by ccowgill View Post
    your current search will put all text in the selection set with the *. If you want to search for the City, Virginia, you may have to put a ` before the comma, so it is read literally as a comma, not as a divide between two text filters. If you could post more of your code, it would be a little easier to tell you how to insert the block. I would assume that you would want to use a condition
    Code:
    (cond
    (
    (setq ssvi (ssget "x" '((0 . "TEXT") (1 . "*`, VIRGINIA"))))
    (command "insert" "whatever the rest of the prompts are")
    )
    (
    (setq sswi (ssget "x" '((0 . "TEXT") (1 . "*, WISCONSIN"))))
    (command "insert" "whatever the rest of the prompts are")
    )
    )
    what have assumed is correct and thanks for help. originally I was just going to put the notes on a palette, but decided to attempt to put this on the end of our titleblock routine, for accuracy sake.

    Quote Originally Posted by irneb View Post
    Yep, that's just it, the comma is used to separate different filter criteria. For example "*test1,*test2" will filter everything ending in either test1 or test2. The way of getting round this is (as ccowgill states) prefixing any control character with a reverse qoute (`). From the developer's help these are the control codes used in wcmatch (which are the same as that used in ssget:
    Code:
    Wild-card characters
    Character           Definition
    #(pound)            Matches any single numeric digit.
    @(at)               Matches any single alphabetic character.
    .(period)           Matches any single nonalphanumeric character.
    *(asterisk)         Matches any character sequence, including an empty one, and it can be used anywhere in the search pattern: at the beginning, middle, or end.
    ?(question mark)    Matches any single character.
    ~(tilde)            If it is the first character in the pattern, it matches anything except the pattern.
    [...]               Matches any one of the characters enclosed.
    [~...]              Matches any single character not enclosed.
    -(hyphen)           Used inside brackets to specify a range for a single character.
    ,(comma)            Separates two patterns.
    `(reverse quote)    Escapes special characters (reads next character literally).
    thanks for the above information, my favorite wildcard is "*", I had a drafter use it to change all the 1's to *, but she did not select the text, she just hit find then replace all, never caught it and saved the drawing, oh what fun she had undo-ing that.

    thanks to both of you for the help

Similar Threads

  1. Replies: 0
    Last Post: 2012-06-06, 11:54 AM
  2. ENTIDADES EN ALIGNMENT COMO "FIXED", "FLOTING" y "FREE"
    By cadia in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2009-02-01, 04:21 AM
  3. How to show "last printed" or "path" text in layout
    By cstone in forum AutoCAD General
    Replies: 3
    Last Post: 2008-11-29, 12:05 AM
  4. HOW switch COMMAND "BLOCK" THE "Scale Uniformly"
    By viz_ken1030 in forum AutoLISP
    Replies: 3
    Last Post: 2006-11-17, 12:41 PM
  5. System variariable for "invert filter" and "apply to layers toolbar" checkboxes
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2005-11-23, 05:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •