Jump to content

Recommended Posts

Posted

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

Posted

Are you able to post your code and an example dwg containing the block with the attribute?

Posted

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

Posted

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)
 )

Posted

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

Posted

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)
 )

Posted

That does it, well done!

 

 

Thanks,

Losinski

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...