AnsweredAssumed Answered

IComponent2::GetBodies3 vs. IPartDoc::GetBodies2

Question asked by Patrick Jensen on Nov 2, 2015
Latest reply on Nov 11, 2015 by Patrick Jensen

In my program, I wish to get the mass of a particular instance of a component in an assembly. Originally, I got the components PartDoc and then used IPartDoc::GetBodies2 and then MassProperty::AddBodies followed by MassProperties::Mass to get the mass. The problem with this is that the bodies that are added do not account for assembly level features of the component whereas IComponent2::GetBodies3 does. From the remarks on IComponent2::GetBody in the API Help:

 

"This method is different from the IPartDoc::Body method in that it recognizes assembly-level features and returns that information based on the component instance. IPartDoc::Body never recognizes assembly-level features because the feature information is kept with the assembly, not propagated down to the part file."

 

Even though this is for IComponent::GetBody, I assume the same applies for IComponent:GetBodies3??? The problem is when the bodies are added using IComponent:GetBodies3, the mass of MassProperty returns 0 every time even though they have the same array of bodies.

.

.

.

BodyArr = swComp.GetBodies3(swSolidBody, "")

BodyArr2 = swPart.GetBodies2(swSolidBody, True)

 

For k = 0 To UBound(BodyArr)

     Debug.Print "Body Name: " & BodyArr(k).Name

Next k

 

For l = 0 To UBound(BodyArr2)

     Debug.Print "Body2 Name: " & BodyArr2(l).Name

Next l

 

Bool = swMass.AddBodies(BodyArr)

Debug.Print "BodyArr Mass: " & swMass.Mass

 

Bool = swMass.AddBodies(BodyArr2)

Debug.Print "BodyArr2 Mass: " & swMass.Mass

.

.

.

 

Returns:

 

Body Name: Boss-Extrude1

Body2 Name: Boss-Extrude1

BodyArr Mass: 0

BodyArr2 Mass: 353.78

 

Any ideas on why this is happening??

Any help is appreciated.

 

Thanks,

 

Patrick

Outcomes