TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

All posts discussing pricing or where to buy TurboCAD will be deleted.

VBScript to list used blocks in a drawing
Read 5437 times
* July 31, 2009, 11:58:55 AM
Someone recently asked for a "purge" script to automatically remove unused blocks. After some initial investigation, I don't yet see a way to get entirely there -- I can list which blocks are presently in use, but I can't find any easy access to the list of blocks in the Blocks panel. So, here's my halfway solution for now.

The attached script will create a sorted text file which lists all blocks that are currently in use in the drawing. From there you'll have to manually delete the unused blocks from the Blocks panel.

I'll keep poking at this -- there must be some way to get the rest of the way there.

[attachment deleted by admin]


* April 15, 2010, 01:35:32 PM
adding the following code

        For Each TCDraw In TCApp.Drawings
            For Each Graphic In TCDraw.Graphics
                TCBlock = Graphic.Block
                name = TCBlock.name
                DumpFile.WriteLine(TCBlock.Name + " used by " + TCDraw.Name)

will show which blocks are used by the various drawings, except if it is in a group.

Coding it for a group is left to reader  ;)

This would be a recursive call I will look at it sometime.