×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VBA macro to determine Mass and Center Of Gravity of a product

VBA macro to determine Mass and Center Of Gravity of a product

VBA macro to determine Mass and Center Of Gravity of a product

(OP)
Hello,
I am trying to create a VBA macro that gets the mass and center of gravity of an assembly depending on the nodes (sub products or sub sub products) I select in the general assembly.
Lets say that my general assembly comprises of several nodes (sub products A,B , C ,D....) and in some of these nodes there are other sub products ( lets say A_1, A_2....)
The aim, if I would do it manually, is to select certain nodes (whether it be at level A or at level A_1) and get the mass and the COG of that configuration (selected nodes)with the measure inertia tool.
So far, with this code I have succeeded in finding the mass and COG of only ONE node:
Sub CATMain()
--------------------------------------------
Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application")
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Set selection1 = productDocument1.Selection
Set product1 = productDocument1.Product
Set products1 = product1.Products
Set product2 = products1.Item("A")
Set products1 = product2.Parent

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))

End Sub
------------------------------------------------------------------
Could someone help me with how to get the inertia properties of a multiple selection (i.e several nodes selected: A_1+A_2+D)? How do I add several nodes(sub products) to a selection and access the inertia properties of that selection (containing several nodes) ?

Thanking you in advance.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources