(How to) change tagname for attdef

Discussion in 'AutoCAD' started by RoNin Warrior, Mar 22, 2005.

  1. Hi there,

    I'm getting a headache trying to change TAG name's for Attribute Deffinitions. (Attributes NOT associated with a block (yet)).

    I'm trying to write a LISP to do this, but somehow, somewhere I'm doing something wrong, and I'm (as a LISP newbie) definately "Lost In ..."

    Any help would be much appreciated !

    Here's my latest code, which returns no errors, but the attdef's don't change as well ... (likely has something to do with the (entmod ...))

    (defun EditAttDef (txtstr / idx A entname entlst tag newtag)
    (setq A (ssget "X" (list '(0 . "ATTDEF"))))
    (if (/= A nil)
    (progn
    (setq idx 0)
    (repeat (sslength A)
    (setq entname (ssname A idx))
    (setq entlst (entget entname))
    (setq tag (strcase (cdr (assoc 2 entlst))))
    (if (and
    (wcmatch (strcase tag)
    (strcase (strcat txtstr "*")))
    (> (strlen tag) (strlen txtstr)))
    (progn
    (setq newtag (strcat txtstr "_" (substr tag (1+ (strlen txtstr)))))
    (entmod (setq entlst (subst newtag tag entlst)))
    ); end progn
    ); end if
    (setq idx (+ idx 1))
    ); end repeat
    ); end progn
    ); end if
    (command "_.regen")
    (princ)
    ); end Function

    (EditAttDef "XR_MAIN")
     
    RoNin Warrior, Mar 22, 2005
    #1
  2. RoNin Warrior

    Jeff Mishler Guest

    What are you trying to change? IOW, what is the tag before and what do you
    expect it to be after?
     
    Jeff Mishler, Mar 22, 2005
    #2
  3. RoNin Warrior

    ECCAD Guest

    Change:
    (entmod (setq entlst (subst newtag tag entlst)))
    To:
    (entmod (setq entlst (subst (cons 2 newtag)(assoc 2 entlst) entlst)))

    Bob
     
    ECCAD, Mar 22, 2005
    #3
  4. Hi Jeff,

    Forgot to mention that part ...

    XR_MAIN1, XR_MAIN2 etc
    Should become XR_MAIN_1, XR_MAIN_2 etc.
     
    RoNin Warrior, Mar 22, 2005
    #4
  5. Yep, that does the trick. It works perfectly now!

    Thnx!!!
     
    RoNin Warrior, Mar 23, 2005
    #5
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.