你的需求是分别导出STP吗?
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
你所说的保存副本是STP还是ipt?
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
以下是根据你这段代码修改的ilogic规则,我这边测试没问题,试下是否满足你的需求
'[ 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 As PartDocument = 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
这是ilogic代码,在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
参照如下操作视频
https://www.bilibili.com/video/BV1iX4y1f73u/
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
你的是2015版本嘛?可能是新版本中的api有简化,我看看找个15版本试试
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