Grrr, I tried dissecting yours but I'm so unfamiliar with the visual lisp functions that's its pretty pathetic on my part. Thanks for the effort. Hopefully you will find a use -David
David, heres some light about it:
vlax-for is visual lisp's alternative to
foreach [vlax-for <obj> <collection>] ~ [foreach <x> <list>]
(vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-get-EffectiveName blk))
means obtaining the block definition's collection [something like (tblobjname "BLOCK" blockname)], but the difference is that collection is something like list, that can be iterated.
(eq "AcDbBlockReference" (vla-get-ObjectName o))
The above means something like:
(eq "INSERT" (cdr (assoc 0 (entget o))))
HTH.
@Grrr1337: Why do you have line 6 in your NestedBlock function?
My fault - thanks for spotting this, Roy!
Re-tested (not experienced with recursions). It was iterating thru the first level only, so this one is should be closer:
(defun NestedBlock
( blk
/ Lst
) )
); cond
); vlax-for
); defun NestedBlock
(defun C:test
( / blk r
) )
)
r
); defun test
Heres a dwg with multi-nested block that can be tested:
http://www.megafileupload.com/p28K/NestTest.dwg
The correct return (I think) would be:
'(NestedRectangleBlocks
(Fifth_And_Sixth
(Fifth Sixth)
)
(FirstSecondThirdFourth
(First_And_Second
(First Second)
)
(Fourth_And_Third
(Fourth Third)
)
)
)
ATM I got:
("Fifth_And_Sixth"
("Fifth" "Sixth")
"FirstSecondThirdFourth"
("First_And_Second" ("First" "Second")
"Fourth_And_Third" ("Third" "Fourth")
)
)
Lee's version flattens them:
("Fifth_And_Sixth" "Sixth" "Fifth" "FirstSecondThirdFourth" "Third" "Fourth" "Fourth_And_Third" "First" "Second" "First_And_Second" "NestedRectangleBlocks")
Atleast I think that it would be more precise to display the nesting tree/levels (that was my older thought).