
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am new to routine programming with Lisp and I don't have much idea of automating the following process:
In a drawing, there are different blocks within a layer called "STRUCTURES", with an attribute called "STRUCPY". Inside that attribute there are different codes separated by commas "," that refer to different elements.
" (619,6XAL,752-N1) ".
The routine must count the number of total elements found in the different blocks.
For example, in my drawing there are three blocks with the following attributes:
BLOCK 1= (619,6XAL,752-N1)
BLOCK 2= (619,752-N1,SPT-023,SPT-023M)
BLOCK 3= (619,752-N1,SPT-023)
The program must print the number of total elements found in the different blocks, so in this case it would print the following:
619= 3
6XAL= 1
752-N1= 3
SPT-023 = 2
SPT-023M = 1
Currently I have a routine that manages to extract the attributes of the different blocks, but now I need to count each of those elements that are in the different blocks. I would be very grateful if anyone can give me some idea how to accomplish that process.
This is the routine to extract the attributes:
(defun c:EC ()
(if (setq ss1 (ssget "_X" '((0 . "insert") (8 . "STRUCTURES"))))
(foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1)))
(foreach AcDbAttrib (vlax-invoke (vlax-ename->vla-object ename) 'getattributes)
(terpri)
(princ (vla-get-textstring AcDbAttrib))
); foreach
(princ "\n------------")
); foreach
); if
(princ)
);defun
Thanks in advance.
Solved! Go to Solution.