| Author |
Message |
Coyote
Guest
|
Posted:
Wed Dec 29, 2004 7:15 pm Post subject:
Global Update Attribute Value with same tag different Blocks |
|
|
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
|
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Wed Dec 29, 2004 9:05 pm Post subject:
Re: Global Update Attribute Value with same tag different Bl |
|
|
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)
)
)
) |
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Wed Dec 29, 2004 9:06 pm Post subject:
Re: Global Update Attribute Value with same tag different Bl |
|
|
Forgot to add the
(ssdel Ent ss)
before the first while ended.
Tim
|
|
| Back to top |
|
 |
BillZ
Guest
|
Posted:
Wed Dec 29, 2004 9:09 pm Post subject:
Re: Global Update Attribute Value with same tag different Bl |
|
|
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 |
|
| Back to top |
|
 |
Coyote
Guest
|
Posted:
Wed Dec 29, 2004 9:13 pm Post subject:
Re: Global Update Attribute Value with same tag different Bl |
|
|
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 |
|
| Back to top |
|
 |
BillZ
Guest
|
Posted:
Wed Dec 29, 2004 9:22 pm Post subject:
Re: Global Update Attribute Value with same tag different Bl |
|
|
You're welcome.
Happy New Year!
Bill |
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Wed Dec 29, 2004 9:24 pm Post subject:
Re: Global Update Attribute Value with same tag different Bl |
|
|
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 |
|
| Back to top |
|
 |
ECCAD
Guest
|
Posted:
Wed Dec 29, 2004 9:35 pm Post subject:
Re: Global Update Attribute Value with same tag different Bl |
|
|
Glad to help out.
Happy New Year (everyone) !
Bob |
|
| Back to top |
|
 |
|
|
|
|