RyanAtHC Posted August 9, 2017 Posted August 9, 2017 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! Quote
BIGAL Posted August 10, 2017 Posted August 10, 2017 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. Quote
RyanAtHC Posted August 10, 2017 Author Posted August 10, 2017 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 Quote
BIGAL Posted August 11, 2017 Posted August 11, 2017 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) Quote
SLW210 Posted August 11, 2017 Posted August 11, 2017 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. Quote
RyanAtHC Posted August 31, 2017 Author Posted August 31, 2017 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! Quote
RyanAtHC Posted August 31, 2017 Author Posted August 31, 2017 http://www.cadforum.cz/cadforum_en/select-dynamic-blocks-by-dynamic-properties-tip7583 this one solves it nicely 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.