我無法弄清楚如何使用VBA宏實例化Power-copy。我有一個CATPart1,它有Power-copy名稱「MyPC」。我想在當前部分中實例化這個電源拷貝。例如,這個Power-copy輸入是:「Plane」,「Start_point」和「End_point」。我在「CAA V5 VB幫助」中發現有InstanceFactory對象,它們具有實例化Power-Copy和UDF的方法。但我的代碼不起作用。在行中出現使用VBA宏在CATIA V5R19中實例化PowerCopy
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"
是否有人幫助我理解爲什麼它不工作? 謝謝你在前進)
你有什麼操作系統?你有沒有安裝更多的CATIA版本?是網絡安裝嗎?什麼是準確的錯誤?你確定你的Power Copy是否正確完成? – ferdo
@ferdo你好。操作系統是Windows 64位。 CATIA V5R19的版本。其他版本未安裝。系統管理員完成安裝。 PowerCopy是正確的,因爲如果我手動實例化它工作正常。錯誤說「運行時錯誤」-2147467259(80004005)':自動化錯誤。未指定的錯誤「。你有什麼想法如何找出爲什麼會出現這個錯誤? –