Mads Hilligsoe

Insert .step into current assembly document

Discussion created by Mads Hilligsoe on Feb 9, 2021
Latest reply on Feb 19, 2021 by Mads Hilligsoe

I'm trying to import a .step file into my current assembly document using a custom C# addin.

I can successfully open a .step file as a new document using the LoadFile4 method (, but when using the InsertImportedComponent method ( i get an error code 2:
sw3DInterconnectImportErrors_IncompatibleType 2 = Specified file type is not correct.

This is my code so far:

IModelDoc2 modDoc = iSwApp.ActiveDoc;
IAssemblyDoc assemblyDoc = (IAssemblyDoc)modDoc;
string stepFileName = "C:\\Users\\mlhil\\MH Tech ApS\\MH Tech - Vaerks\\Udvikling\\CAM\\FeatureCAM Vises\\Vice.step";
object CompObj;
int error = assemblyDoc.InsertImportedComponent(stepFileName, 0, 0, 0, out CompObj);

How do I insert a .step file into my currently active assembly document?