Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Automatically revolving bodies - 3D to 2D axisymmetric

Status
Not open for further replies.

CADlalala

Aerospace
Apr 3, 2014
43
Dear all,

I am trying to write a program in C# in order to automatically extract the faces of a given solid body and revolve all the extracted faces around the Z axis. My final aim is to get the 2D axisymmetric equivalent of any 3D solid body by cutting a section of the resulting set of revolved bodies. The problem I am facing is that some of the faces cannot be revolved (see presentation attached) and if I try to revolve edges instead of faces I get undesirable sliver surfaces.

Have any of you tried to do this before? Does anybody has a bit of code or an idea about how to solve this problem or work around it?

Attached there is a presentation with the (prt)and the code I have written so far is below and attached:
Many thanks,
J



using System;
using NXOpen;
using NXOpen.UF;

public class Program
{
// class members
private static Session theSession;
private static UI theUI;
private static UFSession theUfSession;
public static Program theProgram;
public static bool isDisposeCalled;

//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
public Program()
{
try
{
theSession = Session.GetSession();
theUI = UI.GetUI();
theUfSession = UFSession.GetUFSession();
isDisposeCalled = false;
}
catch (NXOpen.NXException ex)
{
// ---- Enter your exception handling code here -----
// UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
}
}

//------------------------------------------------------------------------------
// Explicit Activation
// This entry point is used to activate the application explicitly
//------------------------------------------------------------------------------
public static int Main(string[] args)
{
int retValue = 0;
try
{
theProgram = new Program();

//TODO: Add your application code here

Session theSession = Session.GetSession();
Part workPart = theSession.Parts.Work;
Part displayPart = theSession.Parts.Display;

foreach (NXOpen.Body body in workPart.Bodies)
{

//Extract Faces
Face[] faces = body.GetFaces();
NXOpen.Features.Feature[] nullFeatures_FeatureArray = new NXOpen.Features.Feature[faces.Length];
NXOpen.Features.ExtractFaceBuilder[] extractFaceBuilderArray = new NXOpen.Features.ExtractFaceBuilder[faces.Length];
extractFaceBuilderArray[0] = workPart.Features.CreateExtractFaceBuilder(nullFeatures_FeatureArray[0]);
extractFaceBuilderArray[0].Type = NXOpen.Features.ExtractFaceBuilder.ExtractType.Face;
bool[] added = new bool[faces.Length];
added[0] = extractFaceBuilderArray[0].ObjectToExtract.Add(faces[0]);
NXObject[] nXobjects = new NXObject[faces.Length];
nXobjects[0] = extractFaceBuilderArray[0].Commit();

for (int i = 0; i < faces.Length + 1; i++)
{

extractFaceBuilderArray = workPart.Features.CreateExtractFaceBuilder(nullFeatures_FeatureArray);
extractFaceBuilderArray.ParentPart = NXOpen.Features.ExtractFaceBuilder.ParentPartType.WorkPart;
extractFaceBuilderArray.Type = NXOpen.Features.ExtractFaceBuilder.ExtractType.Face;
added = extractFaceBuilderArray.ObjectToExtract.Add(faces);
nXobjects = extractFaceBuilderArray.Commit();


NXOpen.Features.Feature nullFeatures_FeatureR = null;
Face[] faces2 = body.GetFaces();
Body[] targetBodies1 = new Body[1];
Body nullBody = null;
targetBodies1[0] = nullBody;
//Section
Section section1;
section1 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5);
//Origin, vector, direction and axis
Point3d origin1 = new Point3d(0.0, 0.0, 0.0);
Vector3d vector1 = new Vector3d(0.0, 0.0, 1.0);
Direction direction1;
direction1 = workPart.Directions.CreateDirection(origin1, vector1, NXOpen.SmartObject.UpdateOption.WithinModeling);
Point nullPoint = null;
Axis axis1;
axis1 = workPart.Axes.CreateAxis(nullPoint, direction1, NXOpen.SmartObject.UpdateOption.WithinModeling);
//Revolve Builder
NXOpen.Features.RevolveBuilder revolveBuilder1;
revolveBuilder1 = workPart.Features.CreateRevolveBuilder(nullFeatures_FeatureR);
revolveBuilder1.Limits.StartExtend.Value.RightHandSide = "0";
revolveBuilder1.Limits.EndExtend.Value.RightHandSide = "360";
revolveBuilder1.Limits.StartExtend.Value.RightHandSide = "0";
revolveBuilder1.Limits.EndExtend.Value.RightHandSide = "360";
revolveBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
revolveBuilder1.BooleanOperation.SetTargetBodies(targetBodies1);
revolveBuilder1.Offset.StartOffset.RightHandSide = "0";
revolveBuilder1.Offset.EndOffset.RightHandSide = "5";
revolveBuilder1.Tolerance = 0.0254;
revolveBuilder1.Section = section1;
revolveBuilder1.Axis = axis1;
section1.DistanceTolerance = 0.0254;
section1.ChainingTolerance = 0.02413;
section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves);
//Faces
Face[] facesOfFeatures1 = new Face[1];
//NXOpen.Features.Brep brep1 = (NXOpen.Features.Brep)workPart.Features.FindObject("UNPARAMETERIZED_FEATURE(1)");
//Face face1 = (Face)brep1.FindObject("FACE 5 {(1789.8054883419686,-471.394872773486,-541.7998006456055) UNPARAMETERIZED_FEATURE(1)}");
facesOfFeatures1[0] = faces;
EdgeBoundaryRule edgeBoundaryRule1;
edgeBoundaryRule1 = workPart.ScRuleFactory.CreateRuleEdgeBoundary(facesOfFeatures1);
//Self-intersection
section1.AllowSelfIntersection(false);
//Necesary code to get the revolve
SelectionIntentRule[] rules1 = new SelectionIntentRule[1];
rules1[0] = edgeBoundaryRule1;
NXObject nullNXObject = null;
Point3d helpPoint1 = new Point3d(792.492921337962, -84.5426421780617, -623.454293084316);
//Revolve the section around the selected axis
section1.AddToSection(rules1, faces2[0], nullNXObject, nullNXObject, helpPoint1, NXOpen.Section.Mode.Create, false);
revolveBuilder1.Section = section1;
revolveBuilder1.Axis = axis1;
revolveBuilder1.ParentFeatureInternal = false;
NXOpen.Features.Feature feature1;
feature1 = revolveBuilder1.CommitFeature();



}


}

}
catch (NXOpen.NXException ex)
{
// ---- Enter your exception handling code here -----

}
return retValue;
}

//------------------------------------------------------------------------------
// Following method disposes all the class members
//------------------------------------------------------------------------------
public void Dispose()
{
try
{
if (isDisposeCalled == false)
{
//TODO: Add your application code here
}
isDisposeCalled = true;
}
catch (NXOpen.NXException ex)
{
// ---- Enter your exception handling code here -----

}
}

public static int GetUnloadOption(string arg)
{
//Unloads the image explicitly, via an unload dialog
//return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly);

//Unloads the image immediately after execution within NX
// return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);

//Unloads the image when the NX session terminates
return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);
}

}
 
 http://files.engineering.com/getfile.aspx?folder=f1379aaf-c431-412f-adc8-5697f8f38b5a&file=Eng_tips_1.zip
Replies continue below

Recommended for you

There is functionality in CAM that may help you.
If you create a turning setup, Mut ZM along the part axis, pick the sold as your part geometry in workpiece, and in turning workpiece set the part spun outline to automatic, a 2D boundary is created for CAM, and a part spun outline feature is created in CAD.


Mark Rief
Product Manager
Siemens PLM
 
 http://files.engineering.com/getfile.aspx?folder=555fe7e4-e8b1-42ec-9998-86ec65a552ff&file=part_spun_outline.jpg
Many thanks for your answer Markrief. The problem that I see in the picture that you attached is that the internal diameter of the "boss" does not appear in the section and also there is still the problem of the sliver geometry (see attached). But actually the real problem here is that we do not have a CAM license as we never had this need before. Therefore, in economic terms it does not make sense for us to hold one. It would be great if someone could think about a workaround in the modelling environment. By the way I am using NX 9.
Thank you!
 
 http://files.engineering.com/getfile.aspx?folder=e8760134-aa09-41a8-8542-17e81bec14fc&file=part_spun_outline2.jpg
Status
Not open for further replies.

Part and Inventory Search

Sponsor