|
[code];;RECURSIVE SEARCH
(defun nw_nestb (b / nt ne nd nb)
(setq nt (tblsearch "BLOCK" b)
ne (cdr (assoc -2 nt)))
(while ne
(setq nd (entget ne))
(and (= "INSERT" (cdr (assoc 0 nd)))
(setq nb (cdr (assoc 2 nd)))
(not (member nb bl))
(setq bl (cons nb bl))
(nw_nestb nb))
(setq ne (entnext ne)) )
(length bl))
;;;MAIN PROGRAM
(defun c:nestblk (/ ss i en ed bn) ; bl
(setq bl nil)
(while (not ss)
(princ "\nSelect Blocks To Search...")
(setq ss (ssget '((0 . "INSERT")))))
(setq i 0)
(while (setq en (ssname ss i))
(setq ed (entget en)
bn (cdr (assoc 2 ed)))
(and (not (member bn bl))
(setq bl (cons bn bl))
(nw_nestb bn))
(setq i (1+ i)))
(setq bl (acad_strlsort bl))
(prin1 bl))[/code] |
|