CATIA VBA how to apply GetTechnologicalObject method to many products
CATIA VBA how to apply GetTechnologicalObject method to many products
(OP)
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





RE: CATIA VBA how to apply GetTechnologicalObject method to many products
Make a list with your products and loop thru them (this can be done in different ways), then you can write results in a file one after another inside the loop.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA how to apply GetTechnologicalObject method to many products
I don't really understand/know what is a list of products? because what I needed to do is apply at once the gettechnologicalobject to many products( and not to only one) to find the mass of one configuration.(My assembly contains several products that sometimes overlap and depending on the configuration I want, I need to deactivate certain products to get one configuration. There are about 2000 configurations)I tried to apply the gettechnologicalobject method to a selection containing many products but in vain.
Howsoever, I found another way to do what I want to do with my code:
http://www.eng-tips.com/viewthread.cfm?qid=427843
RE: CATIA VBA how to apply GetTechnologicalObject method to many products
Another question is: did you checked if all parts have correct density/mass? This will influence your configuration CoG for sure...
If you are using a PDM system it should be there a way to open only a configuration, so you will not need that macro to deactivate certain products and loose time...
I see you are in aeronautics, maybe you have sheet metal parts inside products, I know for example in Airbus you have also the unfolded body inside the part, take care about those, mass for them will be also take in consideration....
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA how to apply GetTechnologicalObject method to many products
I will investigate and tell you later in this thread.