robertbon Posted October 23, 2014 Share Posted October 23, 2014 Is it possible to generate a list of blocks and their sizes in kb? I regularly receive drawing from clients and sometimes the file size is enormous, containing hundreds of blocks. I was hoping to be able to run a routine that would show me which blocks were contributing most to the large file size so I could investigate them and try and get the file size down to something more manageable. Thanks, Rob Quote Link to comment Share on other sites More sharing options...
MSasu Posted October 23, 2014 Share Posted October 23, 2014 You may use BCOUNT to generate the list of inserted blocks and write a script to save those blocks on disk by WBLOCK. After done, sort them in Explorer. -WBLOCK PathToExport NameOfBlock;end of script[code]By the way, this will not treat the not inserted ones. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 23, 2014 Share Posted October 23, 2014 The following will report the number of components within each block - this will not necessarily reveal the largest block definitions in terms of memory usage (since some entities require more memory to define than others), but it may give an overall idea as to which blocks are predominantly contributing to the file size: (defun c:bsize ( / l ) (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (and (= :vlax-false (vla-get-islayout b)) (= :vlax-false (vla-get-isxref b)) ) (setq l (cons (cons (vla-get-name b) (vla-get-count b)) l)) ) ) (if l (progn (princ (LM:padbetween "\nBlock Name" "Components" "." 51)) (princ (LM:padbetween "\n" "" "=" 51)) (foreach x (vl-sort l '(lambda ( a b ) (> (cdr a) (cdr b)))) (princ (LM:padbetween (strcat "\n" (car x)) (itoa (cdr x)) "." 51)) ) (princ (LM:padbetween "\n" "" "=" 51)) ) (princ "\nNo blocks found.") ) (princ) ) ;; Pad Between - Lee Mac ;; Returns the concatenation of two supplied strings padded to a ;; desired length using a supplied character. ;; s1,s2 - [str] strings to be concatenated ;; ch - [str] character for padding ;; ln - [int] minimum length of returned string (defun LM:padbetween ( s1 s2 ch ln ) ( (lambda ( a b c ) (repeat (- ln (length b) (length c)) (setq c (cons a c))) (vl-list->string (append b c)) ) (ascii ch) (vl-string->list s1) (vl-string->list s2) ) ) (vl-load-com) (princ) Regarding the number of references of each of the above blocks, consider using my Nested Block Counter program, or Block Counter program. I hope this helps, Lee Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 24, 2014 Share Posted October 24, 2014 Have a close look at any blocks with names like $aec62Fe45jk these are generally copy and paste blocks and can contain massive amounts of info like complete dwg's, it may be better to save them seperately and use xref's. Quote Link to comment Share on other sites More sharing options...
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.