hi ,
Can anyone please help me to give a lisp;
check all attributes values of few block selection, if there is any att value zero, make all of them empty.
Solved! Go to Solution.
Solved by komondormrex. Go to Solution.
Solved by Moshe-A. Go to Solution.
Solved by komondormrex. Go to Solution.
hey,
do you mean by 'value zero' "0" value or "" value?
=========
if "0" value
(defun c:empty_atts_if_zero (/ insert_sset all_atts_list )
(if (setq insert_sset (ssget '((0 . "insert") (66 . 1))))
(mapcar '(lambda (attribute) (if (= "0" (vla-get-textstring attribute)) (vla-put-textstring attribute "")))
(setq all_atts_list (apply 'append (mapcar '(lambda (insert) (vlax-invoke insert 'getattributes))
(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp
(mapcar 'cadr (ssnamex insert_sset))
)
)
)
)
)
)
)
(princ)
)
updated
@DOODLEANU hi,
check this EMPTYATT command
enjoy
moshe
(defun c:emptyatt (/ ss ent AcDbBlkRef AcDbAttrib)
(if (setq ss (ssget '((0 . "insert") (66 . 1))))
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq AcDbBlkRef (vlax-ename->vla-object ent))
(foreach AcDbAttrib (vlax-invoke AcDbBlkRef 'GetAttributes)
(if (eq (vla-get-textString AcDbAttrib) "0")
(vla-put-textString AcDbAttrib "")
)
(vlax-release-object AcDbAttrib)
)
(vlax-release-object AcDbBlkRef)
); foreach
); if
(princ)
)
how about all blocks with a specific name lets say
block name example Block1
instead of selecting them
check the following
(defun c:empty_atts_if_zero (/ insert_sset all_atts_list )
(if (setq insert_sset (ssget "_x" '((0 . "insert") (66 . 1))))
(mapcar '(lambda (attribute) (if (= "0" (vla-get-textstring attribute)) (vla-put-textstring attribute "")))
(setq all_atts_list (apply 'append (mapcar '(lambda (insert) (vlax-invoke insert 'getattributes))
(vl-remove-if-not '(lambda (insert) (member (strcat (vla-get-effectivename insert))
(mapcar 'strcat '("block1")))
)
(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp
(mapcar 'cadr (ssnamex insert_sset))
)
)
)
)
)
)
)
)
(princ)
)
Can't find what you're looking for? Ask the community or share your knowledge.