Jump to content

Changing X value of Block Attributes with LISP Command


Recommended Posts

Posted (edited)

I want to create a LISP command that will allow me to select a block and move the attributes (block descriptions) to the right (edit the x-coordinate of attribute location). It would be nice if the LISP command used "(setq ss (ssget '((0 . "INSERT"))))" to allow me to select multiple blocks at once and then have all their attributes shift to a specified X coordinate. I don't want to use Bedit, since some of the attributes to the block will be shifted to different locations.

 

Here is the code I have so far. Currently, it will allow me to select multiple blocks and loop through all the attributes to each block. However, I don't know how to only change the X coordinate of each attribute. 

(defun c:shiftatt ( / i ss obj)
(setq i 0)
(if
(and
(setq ss (ssget '((0 . "INSERT"))))
)
(repeat (sslength ss)
(setq obj (vlax-ename->vla-object (ssname ss i)))
(foreach x (vlax-invoke obj 'GetAttributes)

;code to change x-coordinate of each attribute
)
(setq i (1+ i))
)
)
(princ)
)

 

Edited by Benny_Ad
Put code into correct notation
Posted (edited)

If some of the attributes would need to be in different locations as opposed to others, what you would need to do is use a dynamic point parameter and then link the attribute in question to the parameter. After that, you can get the dynamic properties using (vlax-invoke obj 'getdynamicblockproperties) and change the value from there.

 

Edit:

After further inspection, it's actually possible without. Further to your code above:
 

(foreach x (vlax-invoke obj 'GetAttributes)
  (setq pt (vlax-get x 'InsertionPoint))
  (vla-put-insertionpoint x (vlax-3d-point _your_x_value_ (cadr pt) (caddr pt)))
)

 

Edited by Jonathan Handojo
  • Like 1
  • Agree 1
Posted

Another version

 

(setq x 10)
(setq pt2 (mapcar '+ (vlax-get obj 'insertionpoint ) (list  X  0.0 0.0)))
(foreach att (vlax-invoke obj 'GetAttributes)
(vlax-put att 'insertionpoint  pt2)
)

 

  • Like 1

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