简体   繁体   English

SolidWorks Addin 将 STEP 文件导入到当前文档

[英]SolidWorks Addin Import STEP file to current document

I'm trying to import a.step file into my current assembly document using a custom C# addin.我正在尝试使用自定义 C# 插件将 a.step 文件导入到我当前的程序集文档中。

I can successfully open a.step file as a new document using the LoadFile4 method ( http://help.solidworks.com/2020/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.isldworks~loadfile4.html ), but when using the InsertImportedComponent method ( http://help.solidworks.com/2020/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IPartDoc~InsertImportedFeature.html ) i get an error code 2:我可以使用 LoadFile4 方法( http://help.solidworks.com/2020/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.isldworks~loadfile4 .html ), but when using the InsertImportedComponent method ( http://help.solidworks.com/2020/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IPartDoc~InsertImportedFeature.html ) i get an错误代码2:
sw3DInterconnectImportErrors_IncompatibleType 2 = Specified file type is not correct. sw3DInterconnectImportErrors_IncompatibleType 2 = 指定的文件类型不正确。

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);
Debug.Print($"{error}");

How do I insert a.step file into my currently active assembly document?如何将 a.step 文件插入到我当前活动的装配文件中?

Turns out the issue was with my path.原来问题出在我的道路上。 Not sure why, but I cant load the file at the current location.不知道为什么,但我无法在当前位置加载文件。 If i copied the file to C:\ then there was no issue.如果我将文件复制到 C:\ 则没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM