主要目的是使用宏在 Catia 中通过公式链接两个参数。我尝试手动记录该过程,但代码没有给出完整的代码:
Sub CATMain()
Dim partDocument1 As partDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As part
Set part1 = partDocument1.part
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters
Dim parameterSet1 As ParameterSet
Set parameterSet1 = parameters1.RootParameterSet
Dim parameterSets1 As ParameterSets
Set parameterSets1 = parameterSet1.ParameterSets
Dim parameterSet2 As ParameterSet
Set parameterSet2 = parameterSets1.GetItem("Construction_Position")
Dim parameterSets2 As ParameterSets
Set parameterSets2 = parameterSet2.ParameterSets
Dim parameterSet3 As ParameterSet
Set parameterSet3 = parameterSets2.GetItem("R_Point") ' Cannot print the method call put_Value for the object RealParam
Dim relations1 As Relations
Set relations1 = part1.Relations
Set parameterSet3 = parameterSets2.GetItem("R_Point")
Dim formula1 As Formula
Set formula1 = relations1.CreateFormula("Formula.2", "", ' Cannot print the method call CreateFormula for the object Relations
part1.Update
End Sub
我从这个过程“手动”得到的最终公式是
formula.2: Construction_Position\R_Point\R_Point_X=Construction_Position\H_Point\H_Point_X
有人能帮我吗?我试过 CHATGPT,但根本不起作用