Author Topic: Purging Null Blocks  (Read 2342 times)

0 Members and 1 Guest are viewing this topic.

hermanm

  • Guest
Purging Null Blocks
« on: November 05, 2008, 04:21:36 PM »
See attached file.
Free to anyone who needs it.

Major culprits seem to be:

AVE_GLOBAL
AVE_RENDER

I don't use the renderer, so I don't know the specific origin of this trash.
However, this file will get rid of them.

Constructive criticism is always appreciated.

hm

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Purging Null Blocks
« Reply #1 on: November 05, 2008, 04:26:22 PM »
What version of AutoCAD are you using?  Is this a drawing that was created pre-2006?

As of 2006, those blocks (along with the ASAHDE layer) are no longer needed to store rendering information
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Purging Null Blocks
« Reply #2 on: November 05, 2008, 04:32:20 PM »
I would also check the blocks to see if they are xrefs or layouts.  So in your code, I would change this portion.
Code: [Select]
(vlax-for block (vla-get-blocks *thisdwg*);iterate block table
    (if (= 0 (vla-get-count block))
       (setq nullblocks (cons (vla-get-name block) nullblocks))))
to
Code: [Select]
(vlax-for block (vla-get-blocks *thisdwg*);iterate block table
    (if (and
            (= 0 (vla-get-count block))
            (equal (vla-get-IsXref block) :vlax-false)
            (equal (vla-get-IsLayout block) :vlax-false)
        )
       (setq nullblocks (cons (vla-get-name block) nullblocks))))

Also if you don't want to use the command purge, then you could store the block definition, instead of just the name, and use that to delete the block; delete method of the block definition.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

hermanm

  • Guest
Re: Purging Null Blocks
« Reply #3 on: November 05, 2008, 05:59:48 PM »
What version of AutoCAD are you using?  Is this a drawing that was created pre-2006?

As of 2006, those blocks (along with the ASAHDE layer) are no longer needed to store rendering information

The dwgs came to my customer from an outside source. Neither I nor my customer uses render.
Just had some monster files to clean up. Multiple megabyte files which reduced to <200kb by purging INSERTs of the null render blocks.

hermanm

  • Guest
Re: Purging Null Blocks
« Reply #4 on: November 05, 2008, 06:07:17 PM »
I would also check the blocks to see if they are xrefs or layouts.  So in your code, I would change this portion.
Code: [Select]
(vlax-for block (vla-get-blocks *thisdwg*);iterate block table
    (if (= 0 (vla-get-count block))
       (setq nullblocks (cons (vla-get-name block) nullblocks))))
to
Code: [Select]
(vlax-for block (vla-get-blocks *thisdwg*);iterate block table
    (if (and
            (= 0 (vla-get-count block))
            (equal (vla-get-IsXref block) :vlax-false)
            (equal (vla-get-IsLayout block) :vlax-false)
        )
       (setq nullblocks (cons (vla-get-name block) nullblocks))))

Also if you don't want to use the command purge, then you could store the block definition, instead of just the name, and use that to delete the block; delete method of the block definition.

Good points, Tim.
Thanks.

I'll repost the revision a bit later today.