@karpki wrote:
Dear pbejse THANKS again!
It works for me as I wished with a little comment:
Is it possible to
1 make block selection
2 then auto select similar
3 then auto start that code
The sample block name RT-SP is written in the code and code works only with this block name.
There are tens or hundreds of them normally in the working drawing, that's why I'm asking
What you do is add the block names on the bncoll variable
Add the PropertyName names on DpName variable
The "_X" as ssget filter will select all the blcoks on the drawing
(defun c:stripOfRotationValue (/ blknameColl aDocblocks ss i dp bn)
(setq blknameColl nil
aDocblocks (Vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
(setq bncoll '( "RT-SP" "OTHERBLOCK" "ANOTHERBLOCK"))
(setq DpName '( "????1" "_ANGLE1" "ANGLE700"))
(if (setq ss (ssget "_X" '((0 . "INSERT"))))
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(if (and
(member (strcase (vla-get-effectivename e)) bncoll)
(setq dp (vl-some '(lambda (d)
(if (member (vla-get-PropertyName d) DpName)
(list (vlax-get d 'Value) d)
)
)
(vlax-invoke e 'getdynamicblockproperties)
)
)
)
(progn
(vlax-put (cadr dp) 'Value 0.0)
(vlax-put e 'Rotation (Car dp))
)
)
)
)
(princ)
)
or you can make an assocaition list. the first being the block name paired with the target dynamic property name
(defun c:stripOfRotationValue (/ blknameColl aDocblocks ss i dp bn)
(setq blknameColl nil
aDocblocks (Vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
(setq pairs'(("RT-SP" "????1")
("OTHERBLOCK" "_ANGLE1")
("ANOTHERBLOCK" "ANGLE700")))
(if (setq ss (ssget "_X" '((0 . "INSERT"))))
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(if (and
(setq data (assoc (strcase (vla-get-effectivename e)) pairs))
(setq dp (vl-some '(lambda (d)
(if (eq (vla-get-PropertyName d) (Cadr data))
(list (vlax-get d 'Value) d)
)
)
(vlax-invoke e 'getdynamicblockproperties)
)
)
)
(progn
(vlax-put (cadr dp) 'Value 0.0)
(vlax-put e 'Rotation (Car dp))
)
)
)
)
(princ)
)
HTH