Losinski Posted December 8, 2015 Posted December 8, 2015 Hi all, I have made a simple LISP to call on scripts that use the gatte command. The purpose is to adjust my title block fields. Everything works great, except that sometimes the one attribute that is mtext doesn't work. I have figured out that when there is enough text in the attribute value that it goes to the second line, the gatte command won't change it. If the attribute value was spanning over two lines and then reduced to one line it still won't work. The value has to be only one line when the drawing is opened. Anyway, to the point... I need a way to change the value of the attribute "ATT123" in block "BLOCK123" to "AS BUILT". The value of ATT123 is mtext and must remain that way. Any suggestions? Thanks, Losinski Quote
Hippe013 Posted December 8, 2015 Posted December 8, 2015 Are you able to post your code and an example dwg containing the block with the attribute? Quote
Losinski Posted December 10, 2015 Author Posted December 10, 2015 I've attached it to this post. The LISP calls on the following script to change the value of the attribute: GATTE BLOCK "NP TITLEBLOCK INFO" REVDESC AS BUILT Y TEST DRAWING.dwg Quote
Hippe013 Posted December 10, 2015 Posted December 10, 2015 Try this maybe? (defun c:test () (setq sel (nentsel "\nSelect Object: ")) (if sel (progn (setq ent (car sel)) (setq obj (vlax-ename->vla-object ent)) (vlax-put-property obj 'TextString "AS BUILT") ) (princ "\nNothing was Selected:") ) (princ) ) Quote
Losinski Posted December 10, 2015 Author Posted December 10, 2015 That worked, but I need the selection to be automatic. Block name: block123 Attribute name: revdesc123 Can you adjust the lisp to accommodate this? Thanks, Losinski Quote
Hippe013 Posted December 10, 2015 Posted December 10, 2015 Okay.... Try This (defun c:test () (setq ss (ssget "X" '((0 . "INSERT")(2 . "NP TITLEBLOCK INFO")))) (setq sslen (sslength ss)) (setq n 0) (repeat sslen (setq ent (ssname ss n)) (setq obj (vlax-ename->vla-object ent)) (setq att (vlax-invoke-method obj 'GetAttributes)) (setq att (vlax-safearray->list (vlax-variant-value att))) (foreach attref att (if (= "REVDESC" (vlax-get-property attref 'TagString)) (vlax-put-property attref 'TextString "ASBUILT")) ) (setq n (+ 1 n)) ) (princ) ) Quote
Losinski Posted December 10, 2015 Author Posted December 10, 2015 That does it, well done! Thanks, Losinski Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.