Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

CATIA VBA how to apply GetTechnologicalObject method to many products

Status
Not open for further replies.

FabienF

New member
Jul 5, 2017
19
0
0
FR
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
 
Replies continue below

Recommended for you

Thank you Fernando for your response.
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:

 
Getting the mass of one configuration is completely something else...I understand now what you are trying to do and it make sense the other thread (by the way, you can deactivate those products in same way, search all products from your list, select them all (or one by one), deactivate).

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

- Romania
- EU
 
Status
Not open for further replies.
Back
Top