I'm having trouble trying to insert a smart component into an assembly using the API. I followed the example in API Help and everything works fine until I get to the swAssy.AddSmartComponent method. I'm getting the following error -
I'm using SolidWorks 2011 SP5. Here's my code -
Sub InsertComponent(ByVal dblSkPtX As Double, ByVal dblSkPtY As Double, ByVal dblSkPtZ As Double, ByVal strName As String)
Dim strCompModel As String = "C:\\SignalsTest\\680AG-test.SLDPRT"
Dim swAssy As AssemblyDoc
Dim swComponent As Component2
Dim errors As Long
Dim warnings As Long
swApp.OpenDoc6(strCompModel, swDocumentTypes_e.swDocPART, 0, "", errors, warnings)
swModel = swApp.ActivateDoc2("Car Station assy", True, errors)
swAssy = swModel
swComponent = swAssy.AddSmartComponent(strCompModel, dblSkPtX, dblSkPtY, dblSkPtZ) <-- The error occurs here
End Sub
Any ideas?
SolidworksApi macros