@Sea-Haven wrote:
Here is one way
(setq ent (entget (car (nentsel "\nPick attribute"))))
(setq pt (cdr (assoc 10 ent))) ; insert point of attribute
(setq tagname (cdr (assoc 2 ent)))
(setq tagstr (cdr (assoc 1 ent)))
(setq ss (ssget pt (list (cons 0 "Insert"))))
(setq blkname (cdr (assoc 2 (entget (ssname ss 0)))))
@Sea-Haven
I am not sure how o use this.
Below lisp is doing the job for me.
This was written by @DannyNL on this post .
except placing the circles and counting them and showing alert message.
Looking forward to someone to edit to my requirement.
(defun c:fpad_count (/ SB_FindAtt SB_FindVal SB_Selection SB_FoundSel SB_Count SB_BlkEnt)
;(setq SB_FindAtt (getstring "\nAttribute Tag : "))
(setq SB_FindAtt "FWD_PAD")
(setq SB_FindVal (getstring "\nAttribute Value: "))
(if
(setq SB_Selection (ssget "_X" '((0 . "INSERT") (2 . "DA_AMPDATA") (66 . 1))))
(progn
(setq SB_FoundSel (ssadd))
(setq SB_Count 0)
(repeat (sslength SB_Selection)
(setq SB_BlkEnt (ssname SB_Selection SB_Count))
(if
(FindAtt (vlax-ename->vla-object SB_BlkEnt) SB_FindAtt SB_FindVal)
(ssadd SB_BlkEnt SB_FoundSel)
)
(setq SB_Count (1+ SB_Count))
)
(if
(> (sslength SB_FoundSel) 0)
(sssetfirst nil SB_FoundSel)
)
)
)
(princ)
)
(defun FindAtt (FA_BlkObject FA_AttTag FA_AttVal / FA_Attributes FA_Return)
(if
(and
(= (type FA_BlkObject) 'VLA-OBJECT)
(= (vla-get-ObjectName FA_BlkObject) "AcDbBlockReference")
(= (vla-get-HasAttributes FA_BlkObject) :vlax-true)
(= (type FA_AttTag) 'STR)
(= (type FA_AttVal) 'STR)
)
(progn
(setq FA_Attributes (vlax-safearray->list (vlax-variant-value (vla-GetAttributes FA_BlkObject))))
(foreach FA_Item FA_Attributes
(if
(and
(= (strcase (vla-get-TagString FA_Item)) (strcase FA_AttTag))
(= (strcase (vla-get-TextString FA_Item)) (strcase FA_AttVal))
)
(setq FA_Return T)
)
)
)
)
FA_Return
)
Thank you.