问题描述
我不知道如何使用VBA宏实例化Power-copy。我有一个CATPart1,其超级副本名称为 MyPC。我想在当前零件中实例化此超级副本。例如,此超级复制输入为:平面,起点和终点。我在 CAA V5 VB帮助中发现,存在InstanceFactory对象,该对象具有实例化超级副本和UDF的方法。但是我的代码不起作用。
I cant figure out how to instantiate Power-copy using VBA macro. I have a CATPart1, that have Power-copy name "MyPC". And I want to instantiate this power-copy in current Part. Just for example, this Power-copy inputs are: "Plane", "Start_point" and "End_point". I found in "CAA V5 VB help" that there are InstanceFactory object, that have methods to instantiate power-copy and UDFs. But my code doesn't work.
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"
有人可以帮助我了解为什么它不起作用吗?
提前谢谢)
Does anybody help me to understand why it isn't work?Thank you in advance)
推荐答案
有两件事可能是导致您出错的原因:
There are two things that may be the cause of the error you are having:
1-
使用
Dim InstFactory As InstanceFactory
Set InstFactory = part1.GetCustomerFactory("InstanceFactory")
而不是
Dim InstFactory As InstanceFactory
Set InstFactory = part1.HybridShapeFactory
2-您需要激活浮动许可证KT1才能通过API使用PowerCopy操作。要激活它,请转到Catia菜单->工具->选项,然后选择选项卡Shearable Products并激活许可证。
2 - You need to activate the floating license KT1 in order to use the PowerCopy operation via API. To activate it, go to Catia menu -> Tools -> Options and then select the tab Shearable Products and active the license.
这篇关于使用VBA宏在CATIA V5R19中实例化PowerCopy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!