Component.Replace的正确语法是什么?

时间:2014-03-14 14:47:36

标签: vba autodesk

以下是我被告知访问Inventor"更换组件"的正确方法。命令:

Component.Replace(OldNamePath, NewNamePath, False)

但是我收到了语法错误。什么是正确的语法?我在Inventor VBA库中没有看到它......

OldNamePath和NewNamePath来自创建完整路径名的不同模块。

我得到的错误是"预期="错误...

1 个答案:

答案 0 :(得分:1)

"我认为这是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

&#34;