Welcome, Guest. Please login or register.
May 16, 2012, 04:15:25 pm
Home Help Search Login Register
News: Remember to do a search before you ask a question!!!

+  TurboCAD Forums
|-+  SDK Corner
| |-+  Contributions
| | |-+  VBScript to list used blocks in a drawing
« previous next »
Pages: [1] Go Down Print
Author Topic: VBScript to list used blocks in a drawing  (Read 1791 times)
kchapman
Administrator
Full Member
*****
Posts: 201


« on: July 31, 2009, 10: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.
Logged
Andre Arpin
Newbie
*
Posts: 21


« Reply #1 on: April 15, 2010, 12: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)
            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  Wink

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

Andre
Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.05 seconds with 17 queries.