anirudha_kulkarni Posted August 2, 2019 Posted August 2, 2019 Hello Friends, I want to change property value of existing dynamic block. I am new to this language so, please help me with it. Quote
Lee Mac Posted August 2, 2019 Posted August 2, 2019 (edited) You can make use of my library of Dynamic Block Functions; there are plentiful examples on the web of these functions being used in other programs that you can use to learn from. Edited August 2, 2019 by Lee Mac Quote
anirudha_kulkarni Posted August 2, 2019 Author Posted August 2, 2019 Ok thanks for quick reply Lee. I will check that Quote
anirudha_kulkarni Posted August 2, 2019 Author Posted August 2, 2019 Hello Lee, Am I using it right ? Seriously I am newbee I dont know how to program in Autolisp. (defun c:dynamo (/ lst obj sel) (setq ssl (ssget "x" '((0 . "INSERT") (-4 . "<not") (410 . "model") (-4 . "not>"))));setq ;(while (/= (sslength ssl) 0) (setq sslfi (ssname ssl 0)) (setq sslx (cdr (assoc 2 (entget sslfi)))) ; (if (vl-string-search "*" sslx) (setq obj (vlax-ename->vla-object sslfi)) (vlax-property-available-p obj 'IsDynamicBlock) (eq (vla-get-IsDynamicBlock obj) :vlax-true) ;);while (progn (foreach p (vlax-safearray->list (vlax-variant-value (vla-getdynamicblockproperties obj)) ) (if (and (setq a (vlax-get p 'PropertyName)) (setq b (vlax-get p 'AllowedValues)) );and (setq lst (cons (list a b) lst)) );if );foreach (if lst (princ lst) );if );progn (setq val (getstring "\n Enter the desired value")) (LM:setdynpropvalue ( b a val)) (princ) );defun (princ) (defun LM:setdynpropvalue ( obj p val ) (setq p (strcase p)) (vl-some '(lambda ( x ) (if (= p (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 obj 'getdynamicblockproperties) ) ) Quote
Lee Mac Posted August 2, 2019 Posted August 2, 2019 Not quite - there are two elements that you first need to ascertain: the name of the dynamic block parameter that you need to change, and the data type of the parameter value (so that you can prompt the user for the appropriate data). Once you have this information, you can use a program such as the following to set the parameter value (you will need to adjust the property name and user prompt to suit the above): (defun c:dynamo2 ( / i o p s v ) (setq p "YourPropertyName") (cond ( (not (setq s (ssget "_X" '((0 . "INSERT") (410 . "~Model"))))) (princ "\nNo blocks found in Paperspace.") ) ( (/= "" (setq v (getstring "\nEnter the desired value: "))) (repeat (setq i (sslength s)) (setq i (1- i) o (vlax-ename->vla-object (ssname s i)) ) (if (= :vlax-true (vla-get-isdynamicblock o)) (LM:setdynpropvalue o p v) ) ) ) ) (princ) ) (vl-load-com) There is no need to modify the code for my functions in any way, and I would also prefer if you retained the code headers. 1 Quote
anirudha_kulkarni Posted August 5, 2019 Author Posted August 5, 2019 Thank you very much LEE, you are genius.How can I use it on batch files? Quote
anirudha_kulkarni Posted August 8, 2019 Author Posted August 8, 2019 Hello Lee, Please start your youtube channel too to provide Autolisp tutorials. So, newbees like me can get to know Autolisp clearly. Quote
rcb007 Posted March 5 Posted March 5 When a user needs to put in the desired value. What would be a good choice to give the user an option to either (Square Feet or Acres) as input? ( (/= "" (setq v (getstring "\nEnter the desired value: "))) Thanks for the help. Quote
BIGAL Posted March 5 Posted March 5 (edited) Various ways here are 3 use Initget (initget 1 "Sqft or Acres") (setq ans (getkword "\nEnter Sqft or Acres")) (if (= ans "Arces")(do something)) Getstring (if (= v nil)(setq v "Acres")) (setq vans (getstring (strcat "\nEnter the desired value: " v))) (if (= vans nil) (princ) (setq v vans) ) ; disadvantage can enter anything ; advantage is can press Enter for default A user library dcl for input replacement for Initget Edited March 5 by BIGAL 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.