这是我被告知访问 Inventor 的“替换组件”命令的正确方法:
Component.Replace(OldNamePath, NewNamePath, False)
但我收到语法错误。什么是正确的语法?我在 Inventor VBA 库中没有看到它...
OldNamePath 和 NewNamePath 来自创建完整路径名的不同模块。
我得到的错误是“预期=”错误...
“我相信这就是 iLogic 的语法。
每个编程帮助文件都有一个可用的 ComponentOccurence.Replace。
它还包含添加新事件和操作现有事件的示例。”
来自 Autodesk Inventor 自定义论坛。
另外...“您是从 iLogic 还是 VBA 宏执行此操作。如果您是从 iLogic 执行此操作,则命令为 Component.Replace 但参数为:
Component.Replace(componentName, newPath, False) with componentName being the name of the component in the assembly.
如果您从 VBA 宏中执行此操作,则需要设置要更改的组件的 ComponentOccurrance 对象。
Dim occ as ComponentOccurrance
Set occ = (the component occurrance object you want to replace)
//To replace
occ.Replace(newPath, False)"
第三个回应:
"
Public Sub CReplace()
Dim oOccurrence As ComponentOccurrence
Set oOccurrence = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.Item(1)
oOccurrence.Replace "<filename>", True
End Sub
"