chavlji Posted June 7, 2011 Posted June 7, 2011 Hello Does anyone know a program, that can make a "map" of block hierarchy. Example: House ...Doors ...Windows ......curtains ......glass mark Doors Windows ...curtains ...glass mark curtains glass mark So program lists all the blocks and their nested blocks. And nested blocks of nested blocks,... Same I would need to list wich textstyles, layers, dimstyles,... are used where. I need this to do a purge my enormously large drawings. Quote
Lee Mac Posted June 7, 2011 Posted June 7, 2011 I wrote this a little while ago, maybe it will help? (defun c:BlockHierarchy ( / _blockhierarchy blocks ) (vl-load-com) ;; © Lee Mac 2011 (defun _blockhierarchy ( block indent ) (princ "\n") (repeat indent (princ " ")) (princ "|--> ") (princ (vla-get-name block)) (vlax-for obj block (if (eq "AcDbBlockReference" (vla-get-ObjectName obj)) (_blockhierarchy (vla-item blocks (vla-get-name obj)) (1+ indent)) ) ) ) (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for block blocks (if (and (eq :vlax-false (vla-get-isXref block)) (eq :vlax-false (vla-get-isLayout block)) ) (_blockhierarchy block 1) ) ) (princ) ) Quote
chavlji Posted June 7, 2011 Author Posted June 7, 2011 Generally it works for blocks. Thanks. Problem is that my command line only has about 1000 lines, so I can not see all dependances. Quote
Lee Mac Posted June 7, 2011 Posted June 7, 2011 Generally it works for blocks. Thanks.Problem is that my command line only has about 1000 lines, so I can not see all dependances. 1000 lines not enough... how big are your drawings! Maybe write the data to a file: (defun c:BlockHierarchy ( / _blockhierarchy blocks fn fo ) (vl-load-com) ;; © Lee Mac 2011 (defun _blockhierarchy ( block indent ) (princ "\n" fo) (repeat indent (princ " " fo)) (princ "|--> " fo) (princ (vla-get-name block) fo) (vlax-for obj block (if (eq "AcDbBlockReference" (vla-get-ObjectName obj)) (_blockhierarchy (vla-item blocks (vla-get-name obj)) (1+ indent)) ) ) ) (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (if (and (setq fn (vl-filename-mktemp "Block" (vl-filename-directory (getvar 'DWGPREFIX)) ".txt")) (setq fo (open fn "w")) ) (progn (vlax-for block blocks (if (and (eq :vlax-false (vla-get-isXref block)) (eq :vlax-false (vla-get-isLayout block)) ) (_blockhierarchy block 0) ) ) (setq fo (close fo)) (startapp "notepad" fn) ) ) (princ) ) Quote
alanjt Posted June 7, 2011 Posted June 7, 2011 Sounds like someone needs to purge their drawing. Quote
chavlji Posted June 8, 2011 Author Posted June 8, 2011 Sounds like someone needs to purge their drawing. jep I hate autodesk for making it so complicate!!! They could let you purge every item and only warn you that it is used! Development of autocad is dead since R12 if you ask me... Thanks Lee Mac. It works greate now... but I'll improve it some more. I'll post it then here. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.