We are using SolidWorks 2013 SP 3.0. Our toolbar is written in C# with version 21.2.0.50 of the interop assemblies.
Since we have updated to SolidWorks 2013 we have encountered a bug with the method IView::InsertWeldmentTable. I originally thought that I was not cleaning up COM objects correctly, but I was able to reproduce the error with a simple VBA macro.
With .NET, the error comes through as an AccessViolationException. With the VBA macro, the error indicates "The object invoked has disconnected from its clients."
The steps to reproduce are as follows:
- Get the current model file.
- Create a new drawing from any template using SldWorks::NewDocument or ISldWorks::INewDocument2.
- Create a drawing view using IDrawingDoc::CreateDrawViewFromModelView3 or IDrawingDoc::CreateRelativeView.
- The error occurs when attempting to call IView::InsertWeldmentTable.
Can anyone help me resolve this?
The VBA macro to reproduce this error is as follows. To get this to work, place a drawing template named a1 - gb.slddrt in the same location as the macro file.
SolidworksApi macrosDim solidWorks As SldWorks.SldWorks
Sub main()
Set solidWorks = Application.SldWorks
Dim macroPath, macroFolder, templatePath As String
Dim model As ModelDoc2
Dim drawing As DrawingDoc
Dim view As Variant
macroPath = solidWorks.GetCurrentMacroPathName
macroFolder = Left(macroPath, InStrRev(macroPath, "\"))
templatePath = macroFolder & "a1 - gb.slddrt"
Set model = solidWorks.ActiveDoc
Set drawing = solidWorks.NewDocument(templatePath, 0, 0, 0)
Set view = drawing.CreateDrawViewFromModelView3(model.GetPathName, "*Isometric", 0, 0, 0)
view.InsertWeldmentTable True, 0, 0, swBOMConfigurationAnchor_TopRight, "", ""
End Sub