Global Update Attribute Value with same tag different Blocks
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Global Update Attribute Value with same tag different Blocks

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
Coyote
Guest





Posted: Wed Dec 29, 2004 7:15 pm    Post subject: Global Update Attribute Value with same tag different Blocks Reply with quote

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 Reply with quote

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 Reply with quote

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 Reply with quote

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 Reply with quote

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 Reply with quote

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 Reply with quote

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 Reply with quote

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

Bob
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB