brandalf_the_semiGray Posted December 26, 2019 Posted December 26, 2019 Hi there. I'm working on trying to change the color of objects of a selection set that meet certain criteria. Each object in the set contains attribute information for the slopes between adjacent points: NE->SE, NW->SW, SE->SW, NE->NW. I'm attempting to use Lee Mac's getdynpropvalue function in order to compare each slope attributes value against the limits supplied to the function. My code is as follows: (defun updateColor (ss EWmax NSmax / e blk doc) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (repeat (setq i (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (setq blk (vla-item (vla-get-blocks doc) (vla-get-Effectivename e))) (vlax-for x blk (cond ((_inrange (abs (LM:getdynpropvalue x "NENWslope")) 0 EWmax ) (vla-put-color x 1) ) ;end condition 1 ((_inrange (abs (LM:getdynpropvalueLM:getdynpropvalue x "SESWslope")) 0 EWmax ) (vla-put-color x 1) ) ;end condition 2 ((_inrange (LM:getdynpropvalue x "NWSWslope") (- 0 NSmax) NSmax ) (vla-put-color x 1) ) ;end condition 3 ((_inrange (LM:getdynpropvalue (vlax-ename->vla-object x) "NESEslope") (- 0 NSmax) NSmax ) (vla-put-color x 1) ) ;end condition 4 (t (vla-put-color x 3)) ; do this otherwise ) ; end cond ) ; end for ) (vla-regen doc acAllViewports) (princ) ) (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) ) ) (defun _inrange (n ln un) ;function to evaluate whether a slope is in range (<= ln n un) ) When I try to execute the code in AutoCAD I receive the following: error: ActiveX Server returned the error: unknown name: "GETDYNAMICBLOCKPROPERTIES" I'm not sure why I'm getting this error. Maybe I'm not understanding what I'm actually passing to the function. I think that I'm passing individual block objects in to the getdynpropvalue function, which, when I use Lee Mac's routine to dump the allowable methods of the object type that I believe I'm passing, includes the GETDYNAMICBLOCKPROPERTIES method. Any suggestions? Quote
Grrr Posted December 26, 2019 Posted December 26, 2019 Hint: _$ (vlax-invoke (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) "*Model_Space") 'GetDynamicBlockProperties) ; error: ActiveX Server returned the error: unknown name: "GETDYNAMICBLOCKPROPERTIES" Quote
devitg Posted December 26, 2019 Posted December 26, 2019 2 hours ago, brandalf_the_semiGray said: Hi there. I'm working on trying to change the color of objects of a selection set that meet certain criteria. Each object in the set contains attribute information for the slopes between adjacent points: NE->SE, NW->SW, SE->SW, NE->NW. I'm attempting to use Lee Mac's getdynpropvalue function in order to compare each slope attributes value against the limits supplied to the function. My code is as follows: (defun updateColor (ss EWmax NSmax / e blk doc) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (repeat (setq i (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (setq blk (vla-item (vla-get-blocks doc) (vla-get-Effectivename e))) (vlax-for x blk (cond ((_inrange (abs (LM:getdynpropvalue x "NENWslope")) 0 EWmax ) (vla-put-color x 1) ) ;end condition 1 ((_inrange (abs (LM:getdynpropvalueLM:getdynpropvalue x "SESWslope")) 0 EWmax ) (vla-put-color x 1) ) ;end condition 2 ((_inrange (LM:getdynpropvalue x "NWSWslope") (- 0 NSmax) NSmax ) (vla-put-color x 1) ) ;end condition 3 ((_inrange (LM:getdynpropvalue (vlax-ename->vla-object x) "NESEslope") (- 0 NSmax) NSmax ) (vla-put-color x 1) ) ;end condition 4 (t (vla-put-color x 3)) ; do this otherwise ) ; end cond ) ; end for ) (vla-regen doc acAllViewports) (princ) ) (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) ) ) (defun _inrange (n ln un) ;function to evaluate whether a slope is in range (<= ln n un) ) When I try to execute the code in AutoCAD I receive the following: error: ActiveX Server returned the error: unknown name: "GETDYNAMICBLOCKPROPERTIES" I'm not sure why I'm getting this error. Maybe I'm not understanding what I'm actually passing to the function. I think that I'm passing individual block objects in to the getdynpropvalue function, which, when I use Lee Mac's routine to dump the allowable methods of the object type that I believe I'm passing, includes the GETDYNAMICBLOCKPROPERTIES method. Any suggestions? Please, would you upload such sample.DWG Quote
brandalf_the_semiGray Posted December 26, 2019 Author Posted December 26, 2019 (edited) Quote I'm sorry but I'm not sure what to do with that @devitg I uploaded my lisp and my drawing that i've been using for testing dumpSlopes_rev1.lspGS_testing.dwg Edited December 26, 2019 by brandalf_the_semiGray Quote
devitg Posted December 26, 2019 Posted December 26, 2019 Please , what acad do you use. Seem to be it is not plain ACAD. Unknown command "MOVEBLOCKSTOSURFACE" Quote
brandalf_the_semiGray Posted December 26, 2019 Author Posted December 26, 2019 2 minutes ago, devitg said: Please , what acad do you use. Seem to be it is not plain ACAD. Unknown command "MOVEBLOCKSTOSURFACE" Yes, you're correct. This is Civil 3D Quote
devitg Posted December 26, 2019 Posted December 26, 2019 Ok why do you try to explodes ssblocks ? (setvar "qaflags" 1) ;allow explosion of selection sets (command ".explode" blks "") ;explode selection set (setvar "qaflags" 0) ;return qaflags to normal setting Any way it do not explodes . Quote
brandalf_the_semiGray Posted December 26, 2019 Author Posted December 26, 2019 7 minutes ago, devitg said: Ok why do you try to explodes ssblocks ? (setvar "qaflags" 1) ;allow explosion of selection sets (command ".explode" blks "") ;explode selection set (setvar "qaflags" 0) ;return qaflags to normal setting Any way it do not explodes . So the slopes are calculated using attribute fields. In order to get the values to update on screen the encompassing block has to be exploded and then the the drawing regenerated. They currently explode in my drawing and expose the two types of nested blocks. the slope lines run between four separate points that contain elevation information. The slope lines reference the respective elevations of the points in order to calculate % slope between points. I want the color of the slope line block (which contains the circle in the center) to change color based on the values of the attribute fields Quote
devitg Posted December 26, 2019 Posted December 26, 2019 I did not notice that the blocks is a block inside a block . Quote
brandalf_the_semiGray Posted December 26, 2019 Author Posted December 26, 2019 1 minute ago, devitg said: I did not notice that the blocks is a block inside a block . Yes, unfortunately from what I've been able to find, there's no way to update nested attributes and have them display. This was my workaround so that i'd still have an easily place-able block, and have the information and references necessary to make the calculations happen. I am still not sure how to access the values in the block to be able to make a decision on what color the block should be altered to. Any ideas? the problem lies in the update color function I think. I think my issue is I don't understand how to use Lee's function properly. Still pretty new to all things LISP. Quote
devitg Posted December 26, 2019 Posted December 26, 2019 Ok , let me see it . By the way , where are you ? the problem is here (vlax-invoke blk 'getdynamicblockproperties) "TS_SLOPES" is not a DYN block Quote
brandalf_the_semiGray Posted December 26, 2019 Author Posted December 26, 2019 6 minutes ago, devitg said: Ok , let me see it . By the way , where are you ? the problem is here (vlax-invoke blk 'getdynamicblockproperties) "TS_SLOPES" is not a DYN block woah you're totally right. I just assumed it was once i added the attributes. What are some good ways to access the attribute values of a block that isn't dynamic? Quote
devitg Posted December 26, 2019 Posted December 26, 2019 LM has a lot . look for it . http://www.lee-mac.com/attributefunctions.html 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.