FabioDG Posted October 4, 2014 Posted October 4, 2014 Anyone know how to change the value of an action to a dynamic block length using autolisp? Thank you! Quote
Lee Mac Posted October 4, 2014 Posted October 4, 2014 You can use my Set Dynamic Block Property Value function, part of my Dynamic Block Functions. Quote
FabioDG Posted October 4, 2014 Author Posted October 4, 2014 (edited) Impressive, I suspect that this is exactly what needed. But as I do not understand anything VisualLISP not know how to use it. Using their routines, below is what I tried to do to set to "1" the value of a label distance of a dynamic block. Of course it is not working. (defun c:test ( blk prp val ) (setq blk (car (entsel))) ; block name (setq prp "distance1") ; label distance (setq val 1) ; distance value (setq prp (strcase prp)) (vl-some '(lambda (x) (if (= prp (strcase (vla-get-propertyname x))) (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) (cond (val-t## ) # ) (vlax-invoke blk 'getdynamicblockproperties) ) ) Thank you. Edited October 7, 2014 by FabioDG Quote
7o7 Posted October 5, 2014 Posted October 5, 2014 There are some things wrong about your code, I rewrite it and it's fine. (defun c:test (/ blk prp val) (setq blk (vlax-ename->vla-object (car (entsel)))) ; block object (setq prp "distance1") ; label distance (setq val 1) ; distance value (setq prp (strcase prp)) (vl-some '(lambda (x) (if (= prp (strcase (vla-get-propertyname x))) (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) Quote
Lee Mac Posted October 5, 2014 Posted October 5, 2014 Please note that there is no need to modify my code in any way - You should call the function with the required arguments, e.g.: (defun c:test ( / blk ) (if (and (setq blk (car (entsel "\nSelect dynamic block: "))) (setq blk (vlax-ename->vla-object blk)) (= "AcDbBlockReference" (vla-get-objectname blk)) (= :vlax-true (vla-get-isdynamicblock blk)) ) (LM:setdynpropvalue blk "distance1" 1.0) ) (princ) ) ;; Set Dynamic Block Property Value - Lee Mac ;; Modifies the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; val - [any] New value for property ;; Returns: [any] New value if successful, else nil (defun LM:setdynpropvalue ( blk prp val ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) (vl-load-com) (princ) I would appreciate if you retained my code headers when using my code. Quote
7o7 Posted October 5, 2014 Posted October 5, 2014 Sorry Lee Mac, I didn't realize that is your code. Quote
Lee Mac Posted October 5, 2014 Posted October 5, 2014 Sorry Lee Mac, I didn't realize that is your code. No worries. Quote
FabioDG Posted October 5, 2014 Author Posted October 5, 2014 It worked perfectly. I'll wear with your comments. Why not? Thank you. Quote
SLW210 Posted October 6, 2014 Posted October 6, 2014 FabioDG, Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. 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.