paulo Posted October 10, 2018 Share Posted October 10, 2018 Looking for a way to count instances of attribute value of a particular attribute tag. If possible a simple code for me to start with. Thanks. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 10, 2018 Share Posted October 10, 2018 (edited) If I understand correctly, this could be a start : (defun c:att-qty (/ tag val q ss en ed an ad) (while (not (snvalid tag)) (setq tag (strcase (getstring "\nValid TAG Name To Count: ")))) (setq val (getstring t "\nATTRIBute Value To Count: ")) (setq q 0) (and (setq ss (ssget "X" '((0 . "INSERT")(66 . 1)))) (setq i 0) (while (setq en (ssname ss i)) (setq ed (entget en) an (entnext en) ad (entget an)) (while (= "ATTRIB" (cdr (assoc 0 ad))) (and (= tag (cdr (assoc 2 ad))) (= (strcase val) (strcase (cdr (assoc 1 ad)))) (setq q (1+ q))) (setq an (entnext an) ad (entget an))) (setq i (1+ i)))) (alert (strcat (itoa q) " " tag " ATTRIButtes Found")) (prin1)) The ATTRIB values are not case sensitive. -David Edited October 10, 2018 by David Bethel Quote Link to comment Share on other sites More sharing options...
tnvsb Posted October 10, 2018 Share Posted October 10, 2018 Dear Paulo, I got a code that can select the attributes with your input value, So you can see the no.of items in property box(CTRL+1). (defun ssattval (val / ss res ref name blk) (vl-load-com) (or *acad* (setq *acad* (vlax-get-acad-object))) (or *acdoc* (setq *acdoc* (vla-get-ActiveDocument *acad*))) (setq res (ssadd)) (if (ssget "_X" '((0 . "INSERT") (66 . 1))) (progn (vlax-for ref (setq ss (vla-get-ActiveSelectionSet *acdoc*)) (setq has nil) (foreach att (vlax-invoke ref 'GetAttributes) (if (wcmatch (strcase (vla-get-TextString att)) (strcase val)) (setq has T) ) ) (if has (ssadd (vlax-vla-object->ename ref) res) ) ) (vla-delete ss) ) ) (if (< 0 (sslength res)) res ) ) (defun c:SLBKAT (/ val) (if (setq val (getstring "\Enter the value of attribute: ")) (sssetfirst nil (ssattval val)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 10, 2018 Share Posted October 10, 2018 Count Attribute Values Sum Attribute Values 1 Quote Link to comment Share on other sites More sharing options...
paulo Posted October 11, 2018 Author Share Posted October 11, 2018 That is more than just a start, David . Cheers. Tnvsb, I have yet to get my hands on vlisp, Still looking for a good place to start on it, but thanks. Thanks also, Lee for the ready to use codes. I’d really would like to get my head to study your ways. But this will suffice for now. Cheers. Quote Link to comment Share on other sites More sharing options...
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.