【问题标题】:What is the correct syntax for Component.Replace?Component.Replace 的正确语法是什么?
【发布时间】:2014-04-19 22:32:03
【问题描述】:

有人告诉我这是访问 Inventor 的“替换组件”命令的正确方法:

Component.Replace(OldNamePath, NewNamePath, False)

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

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

我得到的错误是“预期 =”错误...

【问题讨论】:

    标签: vba autodesk


    【解决方案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
    

    "

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-14
      • 2019-09-07
      • 1970-01-01
      • 1970-01-01
      • 2023-01-25
      • 1970-01-01
      • 2018-11-22
      相关资源
      最近更新 更多