cancel
Showing results for 
Search instead for 
Did you mean: 

Get moment of inertia from part

Valued Contributor
Valued Contributor
Hello! 
When I use nx open c#, I need to get moment of inertia from part, but I don't know how to do it.
I tried following:
 
foreach (FacetedBody fb in mDisplayPart.FacetedBodies)
{
	mDisplayPart.FacetedBodies.Convert(fb, FacetedBodyCollection.Type.Nx);
        mBodyList.Add(fb);
}


public static void GetPartProps(Tag aBodyTag)
{
	double[] acc_value = new double[11];
        double[] mass_props = new double[47];
        double[] stats = new double[13];
        acc_value[0] = 0.9;
        
        Tag[] taglist = new Tag[1] { aBodyTag };

	gUfSession.Modl.AskMassProps3d(NOtag, 1, 1, 1, 0.0375, 1, acc_value, mass_props, stats);
        
	MessageBox.Show(Convert.ToString(mass_props[2])); //[2] = Mass 
}
But I get exception when it calls gUfSession.Modl.AskMassProps3d() method.
Could you please tell me Where is my mistake?
 
Also, I need to get next parameters:
1) XYZ Moments Of Inertia
2) Mass
3) Center Of Mass
 
Thanks in advance
8 REPLIES

Re: Get moment of inertia from part

Honored Contributor
Honored Contributor

I don't think that you can get mass properties from faceted bodies.

Re: Get moment of inertia from part

Valued Contributor
Valued Contributor
At first I tried to get next properties for Part:
mDisplayPart = aSession.Parts.Display;
 
double[] acc_value = new double[11];
double[] mass_props = new double[47];
double[] stats = new double[13];
acc_value[0] = 0.9;
 
 
//Part ff = (Part)mDisplayPart.OwningPart;
Part ff = mDisplayPart;
Tag[] taglist = new Tag[1] { ff.Tag };               
mUfSession.Modl.AskMassProps3d(taglist, 1, 1, 1, 0.0375, 1, acc_value, mass_props, stats);
MessageBox.Show(Convert.ToString(mass_props[2])); //[2] = Mass 
 
But I got an exception as a result and I decided that for separate FacetedBody it is necessary to get properties as well.
Please advise me a method that could help me to get these parameters ( XYZ Moments Of Inertia, Mass,  Center Of Mass)

Re: Get moment of inertia from part

Honored Contributor
Honored Contributor

The AskMassProps3d function only works on solid or sheet bodies. In the code above, you have passed in the tag of a part file. Each part has a .Bodies collection that you can use to get references to all of the bodies (solid and sheet) owned by that particular part.

Re: Get moment of inertia from part

Valued Contributor
Valued Contributor

Thank you for your explanation.
I successfully got the values in the following way:

foreach (Body sb in mDisplayPart.Bodies)
{
     double[] acc_value = new double[11];
     double[] mass_props = new double[47];
     double[] stats = new double[13];
     acc_value[0] = 0.99;

     Tag[] taglist = new Tag[1] { sb.Tag };
                          
                            
     mUfSession.Modl.AskMassProps3d(taglist, 1, 1, 1, 0.0375, 1, acc_value, mass_props, stats);

     MessageBox.Show(Convert.ToString(mass_props[3]) + " " + Convert.ToString(mass_props[4]) + " " + Convert.ToString(mass_props[5])); //[2] = Mass 
     MessageBox.Show(Convert.ToString(mass_props[2]));
}



However, the values I obtained differ from what I can see in NX10 dialog window:
1) Load the model
2) Analysis -> Measure Bodies
3) Select body
4) Click 'Show Information Window' check box

I can see that inertial parameters obtained via my code above and
shown in the 'Information Window' are different.

Re: Get moment of inertia from part

Honored Contributor
Honored Contributor

Without seeing your part file, my best guess is that two different density values are being used.

 

The measure body function will use whatever density has been applied to the body through the "assign material" function; if no material has been assigned to the body it will use the default value (probably that of steel). Your code uses a density of .0375, instead of whatever has been applied to the body. If the density of the assigned material is different than .0375, you will see different inertial values.

Re: Get moment of inertia from part

Siemens Phenom Siemens Phenom
Siemens Phenom
Also, beware that AskMassProps returns its answers in WCS coordinates (unlike almost every other NX/Open function).
山田
yamada

Re: Get moment of inertia from part

Valued Contributor
Valued Contributor

Thank you very much for helping!

I received proper values by means of next way:

1) Set a material for detail

2) It was necessary to set Units = 4 in the function AskMassProps3d

Could you please tell me how does "density" parameters influence on this method? I changed its value many times but it didn't influence on received values. Is this parameter important? If so, how can I get it before call AskMassProps3d method?

Re: Get moment of inertia from part

Honored Contributor
Honored Contributor

My apologies, I was mistaken about the meaning of the density input. According to the API reference, the density value will be taken from the input solid body. The density value will only have an effect if you specify an analysis type of 2 (thin shell, sheet bodies). In this case, the density value will interpreted as a mass per unit area. This allows you to use sheet bodies to represent thin walled materials.