MACRO LIBRARY

Explode the selected block

Free public access. No account or subscription required.

Files

Explode the selected block

Code

'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
'Explodes a block
    
'Preconditions: Single block is selected in feature manager design tree
'Postconditions: Block is exploded
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swBlockDef As SldWorks.SketchBlockDefinition
Dim swBlockInst As SldWorks.SketchBlockInstance
Dim vBlocks As Variant
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swFeat = swSelMgr.GetSelectedObject6(1, -1)
    Set swBlockDef = swFeat.GetSpecificFeature2
    vBlocks = swBlockDef.GetInstances
    'we don't have to loop through blocks because only one was selected
    Set swBlockInst = vBlocks(0)
    swModel.SketchManager.ExplodeSketchBlockInstance swBlockInst
End Sub