Editing a single attribute via LISP

Discussion in 'AutoCAD' started by SiBanny, Jun 22, 2004.

  1. SiBanny

    SiBanny Guest

    I am trying to write a LISP routine that controls revisions of drawings. Our drawing title block has about 20 attributes in it. I want the routine to edit just one of the attributes (namely, the revision letter) and not touch the rest. Is there any way to do this?

    Any help will be greatly appreciated,

    Cheers

    Simon.
     
    SiBanny, Jun 22, 2004
    #1
  2. SiBanny

    ECCAD Guest

    Do you want to try and code it yourself ?
    You need to grab the block insert (your title block), dig into the attributes, find the 'tag' name of the attribute, and replace the 'value' of that attribute using entmod / entupd. Tricky part is drilling down through the attributes - and - checking the 'existing' value (say it is rev B) - to make it a C.

    Bob
     
    ECCAD, Jun 22, 2004
    #2
  3. SiBanny

    ECCAD Guest

    If you don't want to tackle it, you could .zip a drawing with the Title Block and attach to E-Mail to:

    remove the nospam + .
    I will generate the Lisp, and post it here.
    (no charge)

    Bob
    www.bobscadshop.com
     
    ECCAD, Jun 22, 2004
    #3
  4. here is a quick and dirty program without error checking.
    Change values in "" to your specs

    (setq TitleBlockName "YourTitleBlockName")
    (setq AttributeName "YourAttributeName")
    (setq NewAttributeValue "NewAttributeValue")
    (if (setq SS (ssget "X" (list (cons 0 "INSERT") (cons 2 TitleBlockName))))
    (progn
    (setq EG (entget (ssname SS 0)))
    (setq EN (entget (entnext (cdr (assoc -1 EG)))))
    (while (and (/= (strcase (cdr (assoc 2 EN))) (strcase AttributeName))
    (/= (cdr (assoc 0 EN)) "SEQEND"))
    (setq EN (entget (entnext (cdr (assoc -1 EN)))))
    )
    (if (= (strcase (cdr (assoc 2 EN))) (strcase AttributeName))
    (progn
    (setq EN (subst (cons 1 NewAttributeValue) (assoc 1 EN) EN))
    (entmod EN)
    (entupd (cdr (assoc -1 EG)))
    )
    )
    )
    (princ)
    )
     
    Alan Henderson @ A'cad Solutions, Jun 22, 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.