我在2016版本中测试能够正常导出,没有发现问题。可以试试其他简单的装配或者上传一个导出异常的文件吗
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!
如果我的回帖解决了您的问题,请点击 "接受为解决方案" 按钮. 这可以帮助其他人更快的找到解决方案!
王 承之
Autodesk AGN [Inventor 俱乐部] Leader
Inventor Club | Bilibili
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: 不支持此接口 (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). 在 LmiRuleScript.Main() 在 Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem) 在 iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
上述为报错详细信息
王老师,还是提示如下错误。帮忙分析下,谢谢!
System.InvalidCastException: 无法将类型为“System.__ComObject”的 COM 对象强制转换为接口类型“Inventor.PartDocument”。此操作失败的原因是对 IID 为“{29F0D463-C114-11D2-B77F-0060B0F159EF}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 不支持此接口 (异常来自 HRESULT:0x80004002 (E_NOINTERFACE))。
在 LmiRuleScript.Main()
在 Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
在 iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
用这段
'[ STP转换器设定
Dim oSTEPTranslator As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
']
' 获取当前正在编辑的部件文档对象
Dim assyDoc As AssemblyDocument = ThisApplication.ActiveDocument
' 获取当前部件文档所在的项目文件路径
Dim 工作路径 As String = ThisDoc.WorkspacePath()
' 遍历所有子部件对象
Dim part As ComponentOccurrence
For Each part In assyDoc.ComponentDefinition.Occurrences
' 获取子部件的部件文档对象
Dim partDoc = part.Definition.Document
' 获取零件属性字符串值
Dim 类别 = partDoc.PropertySets.Item("Inventor Document Summary Information").Item("Category").Value
Dim 代号 = partDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
Dim 描述 = partDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
' 如果类别的值为"机加件"或"钣金件"或"铝型材&亚克力",则进行导出操作
If 类别 = "机加件" Or 类别 = "钣金件" Or 类别 = "铝型材&亚克力" Then
'构建文件名
Dim 新文件名 = 工作路径 & "\PDF\" & 类别 & "\" & 代号 & "-" & 描述 & ".stp"
'执行导出
If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
oOptions.Value("ApplicationProtocolType") = 3
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oData As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
oData.FileName = 新文件名
oSTEPTranslator.SaveCopyAs(partDoc, oContext, oOptions, oData)
End If
End If
Next
MsgBox ("完成导出。",,"iLogic")
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!
如果我的回帖解决了您的问题,请点击 "接受为解决方案" 按钮. 这可以帮助其他人更快的找到解决方案!
王 承之
Autodesk AGN [Inventor 俱乐部] Leader
Inventor Club | Bilibili
可以的,得找个时间写一下
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!
如果我的回帖解决了您的问题,请点击 "接受为解决方案" 按钮. 这可以帮助其他人更快的找到解决方案!
王 承之
Autodesk AGN [Inventor 俱乐部] Leader
Inventor Club | Bilibili
本贴盖楼太高了,你可以先把本贴结束掉,另外再开一贴
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!
如果我的回帖解决了您的问题,请点击 "接受为解决方案" 按钮. 这可以帮助其他人更快的找到解决方案!
王 承之
Autodesk AGN [Inventor 俱乐部] Leader
Inventor Club | Bilibili