Jump to content

Size of blocks within a drawing


robertbon

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...