(defun c:SN (/ *error* ActDoc BlkCol Sel EntData BlkName NestList)

(defun *error* ( msg )

(vl-bt)
)
;------------------------------
(defun GetBlockBlocks ( blkObj doc / BlkCol BlkCntList tempList tempName )

(setq BlkCol (vla-get-Blocks doc))
(vlax-for obj blkObj
(if (= (vla-get-ObjectName obj) "AcDbBlockReference")
(setq BlkCntList
(if (setq tempList (assoc (setq tempName (vla-get-Name obj)) BlkCntList))
(subst (list tempName (1+ (cadr tempList)) (caddr tempList)) tempList BlkCntList)
(cons (list tempName 1(GetBlockBlocks (vla-Item BlkCol tempName) doc)) BlkCntList)
)
)
)
)
BlkCntList
)
;-------------------------------------
(defun PrintList ( lst indent )

(prompt (strcat "\n" indent (car lst) " - " (itoa (cadr lst))))
(foreach i (caddr lst)
(PrintList i (strcat " " indent))
)
)
;-------------------------------------
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq BlkCol (vla-get-Blocks ActDoc))
(if
(and
(setq Sel (entsel "\n Select block to get nesting block list: "))
(setq EntData (entget (car Sel)))
(= (cdr (assoc 0 EntData)) "INSERT")
(setq BlkName (cdr (assoc 2 EntData)))
(setq NestList (GetBlockBlocks (vla-Item BlkCol BlkName) ActDoc))
)
(progn
(prompt (strcat "\nReport for:" BlkName))
(foreach lst NestList
(PrintList lst " ")
)
)
)
(princ)
)

Advertisements