Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Journal help needed, I want to measure the mass of solid body in part and apply it to the expression

Status
Not open for further replies.

IvanNX

Mechanical
Jun 9, 2005
267
I want to make a journal that will measure the mass of the solid body in part and apply it to the expression p3000000. I can record Journal clicks, but I do not know VB more than to edit few lines.
Two issues during the journal recording, the first is that when I use to measure body I can't use Selec All to select solids in part, how to do that?
The second is that I do not know how to make a measure to save mass in p3000000 instead of default pX (X=next available number)?


_____________________________
Enjoy your work and have fun!
 
Replies continue below

Recommended for you

Hi
below C# code will create a body measurement in a part file. It will create a single measurement for all the bodies in the part file.
It will exclude sheet bodies and use solids only. Please let me know if this solve your purpose or not. incase if u run any issue you can compile and create a dll. file attached.
====================================================================================================================


using System;
using System.Collections.Generic;
using NXOpen;
using NXOpenUI;


namespace Mass_Solid
{
public class Weight_link
{
public static void Main(string[] args)
{
Session theSession = Session.GetSession();
UI theUi = UI.GetUI();
Part workPart = theSession.Parts.Work;
Part displayPart = theSession.Parts.Display;
ListingWindow lw = theSession.ListingWindow;

BodyCollection ball = workPart.Bodies; //Collect all bodied in the part

List<Body> slds = new List<Body>(); //Solid bodies list

//Checking the body is soldi or not

lw.Open();

foreach (Body b in ball)
{
if (b.IsSolidBody == true)
{
//lw.WriteFullline(b.Tag.ToString());

slds.Add(b);
}

}

if (slds.Count > 0)
{
int ctr = slds.Count;
NXObject nu = null;

MeasureBodyBuilder mb = workPart.MeasureManager.CreateMeasureBodyBuilder(nu);

BodyDumbRule bdr = workPart.ScRuleFactory.CreateRuleBodyDumb(slds.ToArray());

SelectionIntentRule[] scr = new SelectionIntentRule[1];
scr[0] = bdr;
mb.BodyCollector.ReplaceRules(scr, false);

Unit[] massUnits1 = new Unit[5];
Unit unit1 = (Unit)workPart.UnitCollection.FindObject("SquareInch");
massUnits1[0] = unit1;
Unit unit2 = (Unit)workPart.UnitCollection.FindObject("CubicInch");
massUnits1[1] = unit2;
Unit unit3 = (Unit)workPart.UnitCollection.FindObject("PoundMass");
massUnits1[2] = unit3;
Unit unit4 = (Unit)workPart.UnitCollection.FindObject("Inch");
massUnits1[3] = unit4;
Unit unit5 = (Unit)workPart.UnitCollection.FindObject("PoundForce");
massUnits1[4] = unit5;


MeasureBodies mbd = workPart.MeasureManager.NewMassProperties(massUnits1, .99, mb.BodyCollector);

Measure measure1;
measure1 = mbd.CreateFeature();

mbd.Dispose();

mb.Destroy();



}

else
{

theUi.NXMessageBox.Show("Message", NXMessageBox.DialogType.Information, "This part is not having Solid bodies");

}








}
public static int GetUnloadOption(string dummy) { return (int)Session.LibraryUnloadOption.Immediately; }


}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor