Message 1 of 5
Report the number of attributes for each block

Not applicable
03-27-2017
02:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
Please refer to me to the right topic if this question has been asked before. At least I didn't find anything.
I am trying to write the name and number of attributes of each block in my current drawing in a *.txt file (don't care about nested blocks).
I have come this far (for the counting part of task) but I am stuck at this stage:
(defun test1 (VlaObj TagNames TagValues / AttObj TagNam TagVal OutList) (if (and (= 'VLA-OBJECT (type VlaObj)) (= (vla-get-hasattributes VlaObj) :vlax-true) ) (foreach ObjFor (vlax-invoke VlaObj 'GetAttributes) (if (and (wcmatch (setq TagNam (vla-get-TagString ObjFor)) (strcase TagNames)) (wcmatch (strcase (setq TagVal (vla-get-TextString ObjFor))) (strcase TagValues)) ) (setq OutList (cons (list TagNam TagVal (vla-get-ObjectID ObjFor) ObjFor) OutList)) ) ) ) OutList )
I can test singular block with:
(length (test1 (vlax-ename->vla-object (car (entsel))) "*" "*"))
But I can't get it to go through the loop and count the number of attributes for all of the blocks.
I guess reporting the results into a *.txt file shouldn't be a problem (hopefully )