TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
When posting a problem be sure to include which version you are using.  Give as much information as possible.  If the problem is with a specific file be sure to attache it to your post.

VBScript to list used blocks in a drawing
Read 3406 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]

Logged


* April 15, 2010, 01:35:32 PM
#1
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)
            Next
        Next

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.

Andre

Logged