FabienF
New member
- Jul 5, 2017
- 19
Hello,
I need to find the mass and the center of gravity of some bunch of products in an assembly. The code below works for only one product. How do I get the inertia properties of several products at the same time?that is, how to create an object that contains several products to which I can apply the method GetTechnologicalObject.
'--------------------------------------------
Dim catia As Object
Set catia = GetObject(, "CATIA.Application")
Dim productDocument1 As Document
Dim Selection1 As selection
Set productDocument1 = catia.ActiveDocument
Set Selection1 = productDocument1.selection
Set product1 = productDocument1.Product
Set products1 = product1.Products
Set product2 = products1.Item("myproduct")
Dim oInertia As AnyObject
Set oInertia = product2.GetTechnologicalObject("Inertia")
Dim dMass As Double
dMass = oInertia.Mass
Dim dCoordinates(2)
oInertia.GetCOGPosition dCoordinates
MsgBox product2.Name & ": Mass = " & CStr(dMass) & ", Center of gravity : X = " & CStr(dCoordinates(0)) & ", Y = " + CStr(dCoordinates(1)) & ", Z = " + CStr(dCoordinates(2))
'---------------------------------------------
thank you for your help
I need to find the mass and the center of gravity of some bunch of products in an assembly. The code below works for only one product. How do I get the inertia properties of several products at the same time?that is, how to create an object that contains several products to which I can apply the method GetTechnologicalObject.
'--------------------------------------------
Dim catia As Object
Set catia = GetObject(, "CATIA.Application")
Dim productDocument1 As Document
Dim Selection1 As selection
Set productDocument1 = catia.ActiveDocument
Set Selection1 = productDocument1.selection
Set product1 = productDocument1.Product
Set products1 = product1.Products
Set product2 = products1.Item("myproduct")
Dim oInertia As AnyObject
Set oInertia = product2.GetTechnologicalObject("Inertia")
Dim dMass As Double
dMass = oInertia.Mass
Dim dCoordinates(2)
oInertia.GetCOGPosition dCoordinates
MsgBox product2.Name & ": Mass = " & CStr(dMass) & ", Center of gravity : X = " & CStr(dCoordinates(0)) & ", Y = " + CStr(dCoordinates(1)) & ", Z = " + CStr(dCoordinates(2))
'---------------------------------------------
thank you for your help