我想使用CATScript导出CATIA产品的质量。这是我的解决方案:
'Start code
Sub CATMain()
Dim SRT as ProductDocument
Set SRT = CATIA.Documents.Open ("T:\...\SRT_2030.CATProduct")
Set SRT = CATIA.ActiveDocument
Dim oSelection As Selection
Set oSelection = SRT.Selection
Dim oProduct As Selection
Set oProduct = oSelection.FindObject("SRT")
Dim oInertia As AnyObject
Set oInertia = oProduct.GetTechnologicalObject("Inertia")
Dim dMass As Double
dMass = oInertia.Mass
'Display the results
MsgBox dMass
'End code
End Sub
我收到此错误:方法FindObject失败
我做错了什么?
感谢您的帮助!
答案 0 :(得分:0)
您不应该使用Selection对象来完成任务。 而Selection.FindObject接受一个对象类型的参数,它无论如何都不会起作用。
相反,您只需将oProduct设置为您的产品,该产品将是Product Document对象的属性。
...
Set oProduct = SRT.Product
Set oInertia = oProduct.GetTechnologicalObject("Inertia")
...