Jump to content

Recommended Posts

Posted

I have a bunch of dynamic blocks of varying lengths and I have situations where I need to change the attribute text on ones only certain lengths. Quickselect, Find, and Filter do not seem have any other ways I can find search for just the length of the dynamic block. Any info would be very helpful.

 

Thanks!

Posted
You will probably need a lisp, lee-mac has a good properties of a dynamic block routine, so you could search for the length variable and then update the attribute.

 

http://www.lee-mac.com/dynamicblockfunctions.html

 

How much do you know about lisp or else post a sample dwg with dynamic block examples.

 

 

I know very little about lisp. It is definitely something I'd like to learn about though.

 

The example is attached. It is a very dumbed down version of the files I'm working with. I want to be able to search for all the blocks of a certain length, and put the appropriate label on them.

Example.dwg

Posted

This will step through all your dynamic blocks and finds the "Distance1" which is hard coded, where the "alert" is you would do your thing with comparing the distance to the block answer and add your text. I would get the insertion point of the block and use that for the reference offset point of the new text.

 

; Dynamic block Code by Lee-mac
; www.Lee-mac.com

(defun LM:getdynpropvalue ( blk prp )
(setq prp (strcase prp))
(vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
(vlax-invoke blk 'getdynamicblockproperties)
)
)

; check dynamic blocks compare a dynamic value
; By Alan H Aug 2017

(defun c:test ( / objname x obj finalss)
(setq obj (vlax-ename->vla-object (car (entsel "\nPick a block"))))
(setq objname (vla-get-effectivename obj)) 
(setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "`*U*"))))
(setq finalss (ssadd))
(repeat (setq x (sslength ss))
(setq en  (ssname ss (setq x (- x 1))))
(if (=   (vla-get-effectivename (vlax-ename->vla-object en)) objname)
(ssadd en finalss)
)
)
(repeat (setq x (sslength finalss))
(setq obj (vlax-ename->vla-object (ssname finalss (setq x (- x 1)))))
(alert (strcat "length is = " (rtos (LM:getdynpropvalue  obj "Distance1" ) 2 1)))
)
)

(c:test)

  • 3 weeks later...
Posted
This will step through all your dynamic blocks and finds the "Distance1" which is hard coded, where the "alert" is you would do your thing with comparing the distance to the block answer and add your text. I would get the insertion point of the block and use that for the reference offset point of the new text.

 

; Dynamic block Code by Lee-mac
; www.Lee-mac.com

(defun LM:getdynpropvalue ( blk prp )
(setq prp (strcase prp))
(vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
(vlax-invoke blk 'getdynamicblockproperties)
)
)

; check dynamic blocks compare a dynamic value
; By Alan H Aug 2017

(defun c:test ( / objname x obj finalss)
(setq obj (vlax-ename->vla-object (car (entsel "\nPick a block"))))
(setq objname (vla-get-effectivename obj)) 
(setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "`*U*"))))
(setq finalss (ssadd))
(repeat (setq x (sslength ss))
(setq en  (ssname ss (setq x (- x 1))))
(if (=   (vla-get-effectivename (vlax-ename->vla-object en)) objname)
(ssadd en finalss)
)
)
(repeat (setq x (sslength finalss))
(setq obj (vlax-ename->vla-object (ssname finalss (setq x (- x 1)))))
(alert (strcat "length is = " (rtos (LM:getdynpropvalue  obj "Distance1" ) 2 1)))
)
)

(c:test)

 

Sorry I'm just getting around to this. I used the "test" command, and it just gives me the length in a pop up menu with only the okay button for each block. I can't get the getdynpropvalue command to work for some reason. I saved this file as a .lsp from word pad.

 

I'm looking for a way to select the blocks of a certain length. I can change the label attribute in all of them if they are all selected.

 

Thanks!

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