Hi to everyone. I want to use this routine for all blocks in the drawing:
(defun CHGDYNPROP (Ename propname newval / lo obj v vval sal tot i)
(setq obj (if (= (type Ename) 'vla-object)
Ename
(vlax-ename->vla-object Ename))
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
(vlax-put-property (nth i sal) "Value" newval)
(setq i tot)
)
(setq i (1+ i))
)
)
)
(CHGDYNPROP (entlast) "Scale" "1")
(princ)
but because of (entlast) function, it affects only last object in the drawing. what can i do to this lisp routine for affecting to all blocks?
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
@ALPERTOLGAPERCINEL4333 wrote:
Hi to everyone. I want to use this routine for all blocks in the drawing:
but because of (entlast) function, it affects only last object in the drawing. what can i do to this lisp routine for affecting to all blocks?
You know what, i think it would be loads easier if you use _properties <CTRL 1> , But if you want a lisp code then
(defun c:SelectDB ( / ss i) (if (setq ss (ssget "_:L" '((2 . "SCALE BARS,`*U*"))));<-- whatever the block name is (repeat (setq i (sslength ss)) (CHGDYNPROP (ssname ss (setq i (1- i))) "Scale" "1");<-- whatever the property name is ) ) (princ) )
HTH
Thanks for the script but i want to use this routine for different blocks but same visibility names in drawing. Yes, we can do it from the Properties panel with similiar selection but i need to run in lisp. Because this will be a part of another routine.
Untested (I don't have AutoCAD in this laptop), but perhaps something like this
;;Usaqe ;;(dyn_prop "Width" 1200.0) ;; Width >> the property name ;; 1200.0 >> a valid value (vl-load-com) (defun dyn_prop (property newvalue / adoc allval) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for layt (vla-get-layouts adoc) (vlax-for blk (vla-get-block layt) (if (and (= (vla-get-objectname blk) "AcDbBlockReference") (= (vlax-get-property blk 'isdynamicblock) :vlax-true) ) (foreach p (vlax-safearray->list (vlax-variant-value (vla-getdynamicblockproperties blk)) ) (if (and (= (vlax-get p 'PropertyName) property) (vlax-property-available-p p 'Value) (or (not (setq allval (vlax-get p 'allowedvalues))) (member newvalue allval) ) ) (progn (vlax-put-property p 'Value newvalue) (vla-update blk)) ) ) ) ) ) (princ) )
I hope this helps
Henrique
@ALPERTOLGAPERCINEL4333 wrote:
Thanks for the script but i want to use this routine for different blocks but same visibility names in drawing. Yes, we can do it from the Properties panel with similiar selection but i need to run in lisp. Because this will be a part of another routine.
I see, Anyhoo Hmsilva provided a code that will do just that.
Cheers