Little help needed with code

Discussion in 'AutoCAD' started by Matt W, Oct 27, 2004.

  1. Matt W

    Matt W Guest

    How can I determine if a selected block's name has the word "LITE" within
    it??
    What I want to do is start certain program(s) based on the name of a
    selected block.

    I've got multiple blocks called LITE-1, LITE-2, LITE-3, etc... and I'd like
    to be able to select any one of them, then have a program run, in this case,
    MyApp.

    Here's my code:

    Code:
    (defun c:test ( / a ent obj objType)
    (setq a (ssget))
    (setq ent (ssname a 0))
    (setq obj (entget (ssname a 0)))
    (setq objType (cdr (assoc 0 obj)))
    (cond
    ((= objType "INSERT")
    (setq insName (cdr (assoc 2 obj)))
    (cond
    ((= (strcase insName) "*LITE*")  ; this is the problem spot
    (load "MyApp") (c:MyApp)
    )
    ((= T)
    (alert insName)
    )
    )
    )
    )
    (princ)
    )
    
    Thanks in advance!
     
    Matt W, Oct 27, 2004
    #1
  2. Matt W

    Tom Smith Guest

    Use the wcmatch function for the comparison.
     
    Tom Smith, Oct 27, 2004
    #2
  3. Matt W

    T.Willey Guest

    I would use (vl-string-search.....

    Hope that helps
    Tim
     
    T.Willey, Oct 27, 2004
    #3
  4. Matt W

    Don Butler Guest

    Wouldn't this work?

    (ssget (list (cons 0 "INSERT")(cons 2 "LITE*")))

    Don

     
    Don Butler, Oct 27, 2004
    #4
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.