Jump to content

How do you access dynamic block parameters?


scubastu

Recommended Posts

Maybe a silly question, but how do you get a rotation from a dynamic block?

 

My block has scale and rotation dynamic properties in it. The Rotation shows in the Properties bar as Angle1. How can I retrieve this in lisp?

 

Ultimately I want to realign the rotation of the block to another object I select e.g. line, polyline etc..

 

Thanks in advance

Link to comment
Share on other sites

example:

 

(defun c:test ( / ent )
 (vl-load-com)

 (if (setq ent (car (entsel "\nSelect Block: ")))
   (mapcar
     (function
       (lambda (property)
         (vlax-get property 'value)))
     (vlax-invoke
       (vlax-ename->vla-object ent) 'getDynamicBlockProperties))))

Link to comment
Share on other sites

Maybe a silly question, but how do you get a rotation from a dynamic block?

 

My block has scale and rotation dynamic properties in it. The Rotation shows in the Properties bar as Angle1. How can I retrieve this in lisp?

 

Ultimately I want to realign the rotation of the block to another object I select e.g. line, polyline etc..

 

Thanks in advance

 

I hope this will allow you to change parameters

(just one at a time - sorry, not tested)

(defun C:cang(/ ang blk blkname cparam props ss)
 
 (setq blkname "TestBlock" ;<--change block name here
cparam "Angulo");<--change parameter name here
 (setq ang (getreal "\nEnter angle in degrees: ")
ang (/ (* pi ang) 180)
)
 (if (setq ss (ssget ":S" (list
	      (cons 0 "INSERT")
	      (cons 2 (strcat blkname ",`*U*")))))
 (progn
   (setq blk (vlax-ename->vla-object (ssname ss 0)))
   (setq props (vlax-safearray->list 
                     (variant-value 
                     (vla-getdynamicblockproperties blk))))

(foreach param props
(if (eq cparam (vla-get-propertyname param))
   (vlax-put-property param "Value" (vlax-make-variant ang 5))
 (vla-update blk)
 )
 )
)
   )
 (princ)
 )
(vl-load-com)

 

~'J'~

Link to comment
Share on other sites

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