使用 VBA 宏在 CATIA V5R19 中实例化 PowerCopy
Instantiate PowerCopy in CATIA V5R19 using VBA macros
我不知道如何使用 VBA 宏实例化 Power-copy。我有一个 CATPart1,具有 Power-copy 名称 "MyPC"。我想在当前部分实例化这个强大的副本。例如,此 Power-copy 输入为:"Plane"、"Start_point" 和 "End_point"。我在 "CAA V5 VB help" 中发现有 InstanceFactory 对象,它具有实例化 power-copy 和 UDF 的方法。但是我的代码不起作用。
Sub CATMain()
Dim partDocument1 As partDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As part
Set part1 = partDocument1.part
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("gt")
Dim mplane As Plane
Dim StartPnt As point
Dim EndPnt As point
Set mplane = hybridBody1.HybridShapes.Item(1)
Set StartPnt = hybridBody1.HybridShapes.Item(2)
Set EndPnt = hybridBody1.HybridShapes.Item(3)
Dim InstFactory As InstanceFactory
Set InstFactory = part1.HybridShapeFactory
Dim instance
InstFactory.BeginInstanceFactory "MyPC", "D:\myFolder\Part1.CATPart"
InstFactory.BeginInstantiate
InstFactory.PutInputData "Plane", mplane
InstFactory.PutInputData "Start_point", StartPnt
InstFactory.PutInputData "End_point", EndPnt
Set instance = InstFactory.Instantiate
hybridBody1.AppendHybridShape instance
InstFactory.EndInstantiate
End Sub
第
行发生自动化错误
InstFactory.BeginInstanceFactory "MyPC", "D:\myFolder\Part1.CATPart"
有人能帮我理解为什么它不起作用吗?
提前谢谢你)
有两件事可能是您遇到错误的原因:
1 -
使用
Dim InstFactory As InstanceFactory
Set InstFactory = part1.GetCustomerFactory("InstanceFactory")
而不是
Dim InstFactory As InstanceFactory
Set InstFactory = part1.HybridShapeFactory
2 - 您需要激活浮动许可证 KT1 才能通过 API 使用 PowerCopy 操作。要激活它,请转到 Catia 菜单 -> 工具 -> 选项,然后 select 可剪切产品选项卡并激活许可证。
我不知道如何使用 VBA 宏实例化 Power-copy。我有一个 CATPart1,具有 Power-copy 名称 "MyPC"。我想在当前部分实例化这个强大的副本。例如,此 Power-copy 输入为:"Plane"、"Start_point" 和 "End_point"。我在 "CAA V5 VB help" 中发现有 InstanceFactory 对象,它具有实例化 power-copy 和 UDF 的方法。但是我的代码不起作用。
Sub CATMain()
Dim partDocument1 As partDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As part
Set part1 = partDocument1.part
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("gt")
Dim mplane As Plane
Dim StartPnt As point
Dim EndPnt As point
Set mplane = hybridBody1.HybridShapes.Item(1)
Set StartPnt = hybridBody1.HybridShapes.Item(2)
Set EndPnt = hybridBody1.HybridShapes.Item(3)
Dim InstFactory As InstanceFactory
Set InstFactory = part1.HybridShapeFactory
Dim instance
InstFactory.BeginInstanceFactory "MyPC", "D:\myFolder\Part1.CATPart"
InstFactory.BeginInstantiate
InstFactory.PutInputData "Plane", mplane
InstFactory.PutInputData "Start_point", StartPnt
InstFactory.PutInputData "End_point", EndPnt
Set instance = InstFactory.Instantiate
hybridBody1.AppendHybridShape instance
InstFactory.EndInstantiate
End Sub
第
行发生自动化错误InstFactory.BeginInstanceFactory "MyPC", "D:\myFolder\Part1.CATPart"
有人能帮我理解为什么它不起作用吗? 提前谢谢你)
有两件事可能是您遇到错误的原因:
1 - 使用
Dim InstFactory As InstanceFactory
Set InstFactory = part1.GetCustomerFactory("InstanceFactory")
而不是
Dim InstFactory As InstanceFactory
Set InstFactory = part1.HybridShapeFactory
2 - 您需要激活浮动许可证 KT1 才能通过 API 使用 PowerCopy 操作。要激活它,请转到 Catia 菜单 -> 工具 -> 选项,然后 select 可剪切产品选项卡并激活许可证。