cancel
Showing results for 
Search instead for 
Did you mean: 

Center of mass as string

Creator
Creator

Hello,

 

first off I would like to thank anyone who already helped me with my problems in NXOpen. Iam programming in C# and I do have a question again ;-).

 

So I would like to estimate the center of mass of a certain body. When I check the code with the journal via analysis -> measure body, I cannot see a way to get the information I need.

 

I simply need the center of mass to use it for calculation. Could anyone give me a tip how to get the right code to read the com?

 

Thanks in advance.

3 REPLIES

Re: Center of mass as string

Honored Contributor
Honored Contributor

The MeasureBodies object has a .Centroid property that returns a Point3d structure. Since you are using C#, you can use the .ToString method on the Point3d to return the center of mass as a string value.

 

Something like:

com_string = mb.Centroid.ToString;

where mb is the reference to the MeasureBodies object.

Re: Center of mass as string

Creator
Creator

Thank you so much. That worked great :-).

Re: Center of mass as string

Honored Contributor
Honored Contributor

I should note that the resulting string value will not be associative to the COM position. If/when the model changes, the value will not update.

 

If you would like to note the COM on the drawing, you might consider creating a point measurment using the analysis (COM) point, this will create expressions that you can reference in the drawing note. When the model changes, the measurement and resulting expressions (and any notes that reference them) will also update.