Cancel
Showing results for 
Search instead for 
Did you mean: 

Changes in Body Measurement 11.0.1

Experimenter
Experimenter

Hi Guys,

 

I have a code seeing below build in NX 11.0.0.33. It is running without any error and mistakes. Now my colleague want to use it in 11.0.1.11 but the Body Measurement goes wrong. I want to measure all relevant Bodies of each component in an assembly. In the newer version NX only measures one body, the body from the first component of the array (the last component in part navigator). In my older version the body measurement contains each body from all components as it should be.

 

I do not have access to the newer NX Version to take a Journal or test it and I cant find an API DOC for NX11.0.1, but maybe someone of you can help me if there are any changes in the body measurement code from 11.0.0.33 to 11.0.1.11.

 

Excuse me for using Findobject Smiley Wink

 

            //Massenberechnung in NX einfügen
            NXOpen.NXObject nullNXOpen_NXObject = null;
            NXOpen.MeasureBodyBuilder measureBodyBuilder1;
            measureBodyBuilder1 = workPart.MeasureManager.CreateMeasureBodyBuilder(nullNXOpen_NXObject);
            measureBodyBuilder1.InfoWindow = false;


            List<NXOpen.Body> bodies_list = new List<NXOpen.Body>();    //leere Liste für alle Bodies erzeugen
            NXOpen.Body[] bodies_array;             //leeren Bodie Array erzeugen
            workPart.ResetTimestampToLatestFeature();

            NXOpen.Assemblies.ComponentAssembly c = workPart.ComponentAssembly;

            NXOpen.Assemblies.Component[] comp = c.RootComponent.GetChildren(); //alle Komponenten in Array speichern

            for (int k = 0; k < comp.Length; k++)   //Jede Komponente durchzählen

            {
                workPart = MakeBauteilWorkPart(comp[k].DisplayName);    //jede Komponente als Workpart einstellen

                    NXOpen.Body tempbody = (NXOpen.Body)comp[k].FindObject("PROTO#.Bodies|REVOLVED(4)");    //sowohl für Mantel als auch Stutzen sind die Revolve4 die relevanten Bodies
                    bodies_list.Add(tempbody);  //Body der Liste hinzufügen

                workPart = MakeBehaelterWorkPart();
            }
            bodies_array = bodies_list.ToArray();   //Liste in Array umschreiben

                MessageBox.Show(bodies_array.Length.ToString());

            workPart = MakeBehaelterWorkPart();
            NXOpen.BodyDumbRule bodyDumbRule1;
            bodyDumbRule1 = workPart.ScRuleFactory.CreateRuleBodyDumb(bodies_array, true);  //Array mit allen notwendigen Bodies hier nutzen

            NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
            rules1[0] = bodyDumbRule1;
            measureBodyBuilder1.BodyCollector.ReplaceRules(rules1, false);

            //Einheiten für alle vom Feature erzeugten Messungen 
            NXOpen.Unit[] massUnits1 = new NXOpen.Unit[5];
            NXOpen.Unit unit1 = (NXOpen.Unit)workPart.UnitCollection.FindObject("SquareMilliMeter");
            massUnits1[0] = unit1;
            NXOpen.Unit unit2 = (NXOpen.Unit)workPart.UnitCollection.FindObject("CubicMilliMeter");
            massUnits1[1] = unit2;
            NXOpen.Unit unit3 = (NXOpen.Unit)workPart.UnitCollection.FindObject("Kilogram");
            massUnits1[2] = unit3;
            NXOpen.Unit unit4 = (NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter");
            massUnits1[3] = unit4;
            NXOpen.Unit unit5 = (NXOpen.Unit)workPart.UnitCollection.FindObject("Newton");
            massUnits1[4] = unit5;
            NXOpen.MeasureBodies measureBodies1;
            measureBodies1 = workPart.MeasureManager.NewMassProperties(massUnits1, 0.98999999999999999, false, measureBodyBuilder1.BodyCollector);

            NXOpen.Measure measure1;
            measure1 = measureBodies1.CreateFeature();

            string Masse = Math.Round(measureBodies1.Mass, 2).ToString();       //string mit der Masse speichern

            measureBodies1.Dispose();
            measureBodyBuilder1.Destroy();
4 REPLIES

Re: Changes in Body Measurement 11.0.1

Siemens Phenom Siemens Phenom
Siemens Phenom

I'm not sure what error you're enccountering or where it is happening in your code but you can check the NX Open changes in the 11.0.1 Release Notes:

 

https://docs.plm.automation.siemens.com/tdoc/nx/11.0.1/release_notes#uid:index_xid920453:xid920496:x...

 

 

Re: Changes in Body Measurement 11.0.1

Experimenter
Experimenter

Thanks for your help, I did not find this while searching. But sadly there are no changes in Body Measurement Feature or any related code that I used for this.

 

So I try to explain it again and more detailed with english comments.

 

The Code is done in 11.0.0.33 and is fully working. I create a Body Measurement Feature in the assembly. Therefor I loop through each component and choose the relevant Body (Body of Revolve (4)) in each component. One Body for each component so that I get the mass properties of the whole assembly. It is done so that all our assemblies are measured with one click.

 

Now my colleague is using 11.0.1.11 and when using the code only the body of the first component in comp[] (so the last assembled component in the part navigator) is selected in the body measurement. I guess that the misstake could not be in the loop of the component and finding of the relevant body cause the same code is used in other functions and is working well. The misstake have to be in the definition of the body measurement (measureBodyBuilder or something used in this context) cause of any changes from the two versions.

There must be changes in the feature cause when I open the 11.0.1.11 assembly with the buggy Body Measurement in my NX 11.0.0.33 and try to edit it, I am getting a warning that the feature is a future version after conforming the edit of the feature.

 

So I hope that any one can help me if some parts of my code aren't actual for the new version.

 

            //Creating Body Measurement for assembly
            NXOpen.NXObject nullNXOpen_NXObject = null;
            NXOpen.MeasureBodyBuilder measureBodyBuilder1;
            measureBodyBuilder1 = workPart.MeasureManager.CreateMeasureBodyBuilder(nullNXOpen_NXObject);
            measureBodyBuilder1.InfoWindow = false;


            List<NXOpen.Body> bodies_list = new List<NXOpen.Body>();    //creating empty list for all bodies that should be selected by the body measurement feature
            NXOpen.Body[] bodies_array;             //empty body array
            workPart.ResetTimestampToLatestFeature();

            NXOpen.Assemblies.ComponentAssembly c = workPart.ComponentAssembly;

            NXOpen.Assemblies.Component[] comp = c.RootComponent.GetChildren(); //getting all components in comp[]

            for (int k = 0; k < comp.Length; k++)   //looping each component of the assembly

            {
                workPart = MakeBauteilWorkPart(comp[k].DisplayName);    //make each component workPart

                    NXOpen.Body tempbody = (NXOpen.Body)comp[k].FindObject("PROTO#.Bodies|REVOLVED(4)");    //find each relevant body (Revolved(4)) for each component
                    bodies_list.Add(tempbody);  //Add the found body to list

                workPart = MakeBehaelterWorkPart(); //make assembly workPart
            }
            bodies_array = bodies_list.ToArray();   //Save body list into array

                MessageBox.Show(bodies_array.Length.ToString()); //this shows me that the looping through components and bodies is right in both NX versions

            workPart = MakeBehaelterWorkPart(); //make Assembly workPart
            NXOpen.BodyDumbRule bodyDumbRule1;
            bodyDumbRule1 = workPart.ScRuleFactory.CreateRuleBodyDumb(bodies_array, true);  //using the body array to add thos to selection of the body measurement feature

            NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
            rules1[0] = bodyDumbRule1;
            measureBodyBuilder1.BodyCollector.ReplaceRules(rules1, false); //using the rule of above

            //finding the units that need to be used in the body measurement 
            NXOpen.Unit[] massUnits1 = new NXOpen.Unit[5];
            NXOpen.Unit unit1 = (NXOpen.Unit)workPart.UnitCollection.FindObject("SquareMilliMeter");
            massUnits1[0] = unit1;
            NXOpen.Unit unit2 = (NXOpen.Unit)workPart.UnitCollection.FindObject("CubicMilliMeter");
            massUnits1[1] = unit2;
            NXOpen.Unit unit3 = (NXOpen.Unit)workPart.UnitCollection.FindObject("Kilogram");
            massUnits1[2] = unit3;
            NXOpen.Unit unit4 = (NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter");
            massUnits1[3] = unit4;
            NXOpen.Unit unit5 = (NXOpen.Unit)workPart.UnitCollection.FindObject("Newton");
            massUnits1[4] = unit5;
            NXOpen.MeasureBodies measureBodies1;
            measureBodies1 = workPart.MeasureManager.NewMassProperties(massUnits1, 0.98999999999999999, false, measureBodyBuilder1.BodyCollector);  //creating the body measurement

            NXOpen.Measure measure1;
            measure1 = measureBodies1.CreateFeature();  //creating the feature

            string Masse = Math.Round(measureBodies1.Mass, 2).ToString();       //string mit der Masse speichern  //getting the mass into string that is used in further code

            measureBodies1.Dispose();
            measureBodyBuilder1.Destroy();

Re: Changes in Body Measurement 11.0.1

Esteemed Contributor
Esteemed Contributor

dombeh wrote:

...

The Code is done in 11.0.0.33 and is fully working. I create a Body Measurement Feature in the assembly. Therefor I loop through each component and choose the relevant Body (Body of Revolve (4)) in each component. One Body for each component so that I get the mass properties of the whole assembly. It is done so that all our assemblies are measured with one click.

 


Are you saying you check "Body of revolve(4)" in each component?  That sounds way too specific. If you check the 4th feature, it could be there's not even a body at that point.  (or it could be I'm not understanding your translation to English :-)

 

1) Are you both using the same assembly for testing?

a) If not, have the other user try your assembly, and you try the other user's assembly.  It could be an issue with how one of the parts is modeled.

2) I would try listing each individual components properties (e.g. to listing window) to see if/how they differ between you & the other user.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Changes in Body Measurement 11.0.1

Experimenter
Experimenter

The code should only work for specific components. All those components have a Revolve Feature at Timestamp 4 which body should be used. So there is no problem that the body can not be found.

 

The assemblies are the same.