muck Posted September 8, 2010 Posted September 8, 2010 Is there a VBA routine that will purge all unused or unreferanced blocks in VBA? I notice if I use ThisDrawing.PurgeAll that there is some remaining referanced blocks in my drawing. If a manually purge them those unreferance blocks disappear. So is there a VBA Routine to purge all unused or unreferanced blocks with VBA? Thank you, Quote
BlackBox Posted September 10, 2010 Posted September 10, 2010 One option (of many)... would be to step through a selection of all blocks in the drawing, storing their EffectiveName to a LayerNameList variable. Then foreach block in the block collection, if the EffectiveName is not a member of the LayerNameList, then delete (from the block collection). :wink: Hope this helps! Quote
PeterPan9720 Posted September 18, 2010 Posted September 18, 2010 I use selection set Dim Block As AcadBlockReference For Each Paperino In ThisDrawing.SelectionSets If Paperino.name = "BOM" Then ThisDrawing.SelectionSets("BOM").Delete Exit For End If Next Dim PT1(0 To 2) As Double Dim PT2(0 To 2) As Double PT1(0) = 0# 'X PT1(1) = 0# 'Y PT1(2) = 0# 'Z PT2(0) = 170# 'X1 PT2(1) = 260# 'Y1 PT2(2) = 0# ' Z1 GC(0) = 0 GC(1) = 2 GV(0) = "INSERT" '--------------------------------------------------- 'Revise the block name "tendnum1" for your application GV(1) = "$Conf*" intCode(0) = 0: intCode(1) = 2: '--------------------------------------------------- ThisDrawing.SelectionSets.Add ("BOM") Set Ssnew = ThisDrawing.SelectionSets("BOM") Ssnew.Select acSelectionSetCrossing, PT2, PT1, intCode, GV For Each Entity In Ssnew Set Block = Entity BlockName = Block.name If Left$(BlockName, 5) = "$Conf" Then Block.Delete next Quote
Recommended Posts
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.