I have a program that exports a SolidWorks drawing to a DXF. The drawing has a block in it and when it is exported the block location changes. Apparently this is a bug in SolidWorks. As a workaround you can explode the block before you export it and the location doesn't change. My problem is when I try to programmatically explode the block it doesn't work.
This is what the drawing looks like before I explode the block
This is what the drawing looks like after I explode the block
My code is below. Any ideas?
Dim swSketchMgr As SldWorks.SketchManager
Dim vBlockDefs As Object
Dim vBlockInst As Object
Dim swBlockDef As SldWorks.SketchBlockDefinition
Dim swBlockInstance As SldWorks.SketchBlockInstance
Dim x As Integer = 0
Dim y As Integer = 0
swSketchMgr = swModel.SketchManager
vBlockDefs = swSketchMgr.GetSketchBlockDefinitions
If Not vBlockDefs Is Nothing Then
For x = 0 To UBound(vBlockDefs)
swBlockDef = vBlockDefs(x)
vBlockInst = swBlockDef.GetInstances
For y = 0 To UBound(vBlockInst)
swBlockInstance = vBlockInst(y)
swSketchMgr.ExplodeSketchBlockInstance(swBlockInstance)
Next
Next
End If
SolidworksApi macros