wild card match with blocks

Discussion in 'AutoCAD' started by mnash, Mar 16, 2005.

  1. mnash

    mnash Guest

    I'm having a lot of difficulty with wcmatch.
    I have a situation where I have a block in a drawing. One department would have to worry about it, another department will not. So I have a condition set up such that if a block with name ICON-01 exists, then do the following. If it don't exist, skip the instructions to do something else. The thing is, there also may be a block with name ICON-02, ICON-03 and so on.
    So, I was hoping to do a tablsearch for ICON*, but I understand wcmatch and tblsearches don't get along well together. I did find a long way around that. Once I have the block, i wanted to set it to a variable so that I can change the properties of the block 41, 42 & 43 to a scale varialbe b_scl.

    I know this is an aweful lot to ask.
    Does anyone know of a real good lisp literature, from basics to advanced? I'd like to put something back into this discussion group.
    Thanks all
    MN
     
    mnash, Mar 16, 2005
    #1
  2. mnash

    Jürg Menzi Guest

    Hi mnash

    How about:
    Code:
    (if (ssget "X" '((0 . "INSERT") (2 . "ICON-01")))
    (DoICON-01Stuff)
    (DoTheOtherStuff)
    )
    
    Cheers
     
    Jürg Menzi, Mar 16, 2005
    #2
  3. mnash

    mnash Guest

    I've already come up with that, the problem is that "2" may be ICON-02, ICON-03 and so on, can I filter out the last two characters of the name of the block? Then I need to set that block to a variable to change the scale properties, I would just like to replace them instead of going through the scale command.
    Still workin' on it
     
    mnash, Mar 16, 2005
    #3
  4. mnash

    BillZ Guest

    Then how about this?

    Code:
    ;Usage: (GetBlocks "StingToSearchFor")
    ;
    (defun GetBlocks (StrngTxt / cnt elst enm NameList ss1)
    (vl-load-com)
    (setq ss1 (ssget "X" '((0 . "INSERT")))
    cnt 0
    )
    (repeat (sslength ss1)
    (setq enm (ssname ss1 cnt)
    elst (entget enm)
    cnt (1+ cnt)
    )
    (if (wcmatch (cdr (assoc 2 elst))(strcat StrngTxt "*"))   ;gets any name that begins with StrngTxt
    (setq NameList (cons (cdr (assoc 2 elst)) NameList)   ;do whatever here.
    )
    )
    )
    NameList
    )
    Bill
     
    BillZ, Mar 16, 2005
    #4
  5. mnash

    Jürg Menzi Guest

    Hi mnash
    (ssget "X" '((0 . "INSERT") (2 . "ICON-##")))
    '##' = two numbers
    '??' = two characters
    But you know then you get all matching blocks...

    Cheers
     
    Jürg Menzi, Mar 16, 2005
    #5
  6. mnash

    mnash Guest

    that seems to work, now I think I can move forward.
     
    mnash, Mar 16, 2005
    #6
  7. mnash

    Jürg Menzi Guest

    Glad to help...¦-)

    Cheers
     
    Jürg Menzi, Mar 16, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.