Manuel_Kunde Posted October 22, 2021 Share Posted October 22, 2021 Hi all, I have a dynamic block named "console" and want to read the attribute from the block "first_pos". I have found many routines that require user input, but I want to run the whole thing in the background. Quote Link to comment Share on other sites More sharing options...
mhupp Posted October 22, 2021 Share Posted October 22, 2021 (edited) Here is an assortment of lisp for dynamic block I came across awhile ago. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-manipulate-a-dynamic-block-with-lisp/m-p/1605323/highlight/true#M208093 Shows what variables there are in your block Reads a given variable in your block Changes a given variable in your block Returns a selection set of blocks with the same effective name Find dynamic blocks with the same effective name Type the following and it will display the attribute. (getdynprop (entsel) "first_pos") ;;---------------------------------------------------------------------- ;; Reads a given variable in your block (defun getdynprop (e propname / obj v vval sal tot i curval) (setq obj (if (= (type e) 'vla-object) e (vlax-ename->vla-object e))) (if (= (vlax-get-property obj 'isdynamicblock) :vlax-true) (progn (setq v (vla-getdynamicblockproperties obj) vval (vlax-variant-value v) sal (vlax-safearray->list vval) tot (length sal) i 0 ) (while (< i tot) (if (= (vlax-get-property (nth i sal) "PropertyName") propname) (progn (setq curval (vlax-get-property (nth i sal) "Value")) (setq i tot) ) (setq i (1+ i)) ) ) ) ) (if curval (vlax-variant-value curval)) ) Edited October 22, 2021 by mhupp 1 Quote Link to comment Share on other sites More sharing options...
Manuel_Kunde Posted October 22, 2021 Author Share Posted October 22, 2021 35 minutes ago, mhupp said: Reads a given variable in your block Thank's so far. Should i change "PropertyName" and "Value" in the routine? (if (= (vlax-get-property (nth i sal) "PropertyName") propname) (progn (setq curval (vlax-get-property (nth i sal) "Value")) (setq i tot) ) (setq i (1+ i)) ) Btw is it possible to do this without user input? Quote Link to comment Share on other sites More sharing options...
mhupp Posted October 22, 2021 Share Posted October 22, 2021 (edited) 1 hour ago, Manuel_Kunde said: Should i change "PropertyName" and "Value" in the routine? Btw is it possible to do this without user input? I would just add the read lisp to the bottom of your lips and use the call function to read out the attribute. rather then trying to modify it to only read "first_pos" "PropertyName" and "Value" are like the dxf codes headers So its looking at each "PropertyName" in the block until it equals "first_pos" then what ever that "Value" it's set curval Yes its possible I would have to look at your code to see how your selecting the block. If your using ssget would be something like (getdynprop (ssname SS #) "first_pos") if your using something like (setq x (entsel )) (getdynprop x "first_pos") This is just a simple lisp. (defun C:FPOS (\ ss pos) (if (setq SS (ssget "_X" '((0 . "INSERT") (2. "console")))) (foreach x (mapcar 'cadr (ssnamex SS)) (setq pos (getdynprop x "first_pos")) (if (setq npos (getstring (strcat "\nChange Value of POS <" pos ">: ")) (chgdynprop x "first_pos" npos) ) ) ) ) ;have the read variable & change variable lisp loaded When they type FPOS it will select all console blocks. it will then display the value of first_pos and ask for input Value of POS <15>: 5 If you enter anything it will then change first_pos to the new value. Edited October 22, 2021 by mhupp 2 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 22, 2021 Share Posted October 22, 2021 (edited) Another, I use this and get block visibility properties to set visibility states using a dcl to set rather than the block arrow. Preset values can be added also when inserting the block. I use it to set the X & Y sizes of the block to fit in a rectang just pick inside the rectang. http://www.lee-mac.com/dynamicblockfunctions.html Edited October 22, 2021 by BIGAL Quote Link to comment Share on other sites More sharing options...
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.