AnsweredAssumed Answered

Explode Block

Question asked by Chris Angevine on Apr 20, 2015

I'm trying to write a macro that will explode all of the blocks in a drawing.

I have one that will get all the blocks in the drawing and delete them.  It is shown below.  From what I've seen in Help, they keep referring to an instance of the block.  Do I need to iterate through each instance and explode?  If so, anyone know how I get started?

 

Thanks, Chris

 

Dim swDoc As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSketchMgr As SldWorks.SketchManager
Dim swSketchBlockDef As SldWorks.SketchBlockDefinition
Dim vSketchBlockDefs As Variant
Dim vSketchBlockDef As Variant
Dim retval As Variant

Sub Main()

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set swSketchMgr = swDoc.SketchManager

vSketchBlockDefs = swSketchMgr.GetSketchBlockDefinitions

For Each vSketchBlockDef In vSketchBlockDefs

    Set swSketchBlockDef = vSketchBlockDef
    Set swFeat = swSketchBlockDef.GetFeature
     Debug.Print swFeat.Name
     retval = swFeat.Select2(False, -1)
    retval = swDoc.DeleteSelection(False)

Next

End Sub

Outcomes