Global Update Attribute Value with same tag different Blocks

Discussion in 'AutoCAD' started by Coyote, Dec 29, 2004.

  1. Coyote

    Coyote Guest

    Hi Everyone,

    Hope your holidays were safe and happy. If have a situation where I need to globally update a specific attribute tag "DWGNO" that used in a couple different blocks within a drawing. I know I can use (ssget "x" '((0 . "Insert") (66 . 1))) to select all the blocks but after reviewing the many postings relating to this subject i get bogged down in how to efficiently use code to modify the attribute value.

    In Summary what I need is to create a routine that updates all occurrences of the tag "DWGNO" with the value from (setq ShtNo (getvar "Dwgname")).

    Thanks In advance
    Coyote
     
    Coyote, Dec 29, 2004
    #1
  2. Coyote

    T.Willey Guest

    Should be something like this. Written on the fly.

    Tim

    (setq ss (ssget "x" '((0 . "INSERT") (66 . 1))))
    (while (setq Ent (ssname ss 0))
    (setq Att Ent)
    (while (/= (cdr (assoc 0 (entget Att))) "SEQEND")
    (setq Att (entnext Att))
    (if (= (cdr (assoc 2 (entget Att))) "DWGNO")
    (entmod (cons 1 (getvar "dwgname")) (assoc 1 Att) Att)
    )
    )
    )
     
    T.Willey, Dec 29, 2004
    #2
  3. Coyote

    BillZ Guest

    Well heck,
    It's the holidays.

    Code:
    ;;12/29/04 Bill Zondlo
    ;;Pick Insert and change tag named "DWGNO"'s text string to dwgname.
    ;;
    (defun c:NameAttrb (/ AttObj AttLst BlkObj cnt ent ss)
    (vl-load-com)
    (setq ss (ssget "X" '((0 . "INSERT") (66 . 1)))
    )
    (setq cnt 0)
    (repeat (sslength ss)
    (setq ent (ssname ss cnt)
    cnt (1+ cnt)
    )
    (setq BlkObj (vlax-ename->vla-object ent)
    AttObj (vla-getAttributes blkobj)
    AttLst (vlax-SafeArray->List (vlax-variant-value AttObj))
    )
    (foreach n AttLst
    (if (= (vla-get-tagstring n) "PROGRAM");(= (vla-get-tagstring n) "DWGNO")
    (vla-put-TextString n (getvar "dwgname"))
    )
    )
    )          ;end repeat
    )
    Bill
     
    BillZ, Dec 29, 2004
    #3
  4. Coyote

    Coyote Guest

    Gentleman,

    Tried everyone of you ideas and they all worked great, its always interesting to see how many different ways there are to solving a problem.

    many thanks again
    Coyote
     
    Coyote, Dec 29, 2004
    #4
  5. Coyote

    BillZ Guest

    You're welcome.

    Happy New Year!

    Bill
     
    BillZ, Dec 29, 2004
    #5
  6. Coyote

    T.Willey Guest

    I love seeing all the other ways people do it also, it's a great way to learn.

    Glad you got something that works for you.

    Tim
     
    T.Willey, Dec 29, 2004
    #6
  7. Coyote

    ECCAD Guest

    Glad to help out.
    Happy New Year (everyone) !

    Bob
     
    ECCAD, Dec 29, 2004
    #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.