Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Edge Blend and 2 unite cylinder

Builder
Builder

Hello Everyone

Here is code for edge  blend of 2 cylinder and uniting them.

Problem is that sometimes front edge is getting selected and sometimes back edge of a cylinder gets selected.

And this happening in the code itself without changing it.

 

How can I select one specific edge say I want to select front edge of the cylinder?

As shown below snapshot.

RightOne.PNGThis is Right ImageWrong one 1 cylinder backside and 2 cylinder front side.PNGThis is wrong Image

Some times code gives above result also that is wrong image.

How can I remove this shuffling of edges of cylinder?

 

Thank You

 

 

 

 

using System;
using NXOpen;
using NXOpen.Features;

public class NXJournal
{
public static NXOpen.Features.Cylinder theCylinder1;
public static void Main(string[] args)
{

CreateEdgeBlendCylinder();
CreateSmallEdgeBlendCylinder();
}

public static void CreateEdgeBlendCylinder()

{
double radius = 5.0;
double diameter = 120;
double height = 70;

Session s = Session.GetSession();
Part workpart = s.Parts.Work;
Point3d theorigin = new Point3d(0, 0, 0);
Point thepoint = workpart.Points.CreatePoint(theorigin);
Vector3d thevector = new Vector3d(1, 0, 0);
Direction thedirection = workpart.Directions.CreateDirection(theorigin, thevector, SmartObject.UpdateOption.WithinModeling);
CylinderBuilder cylinderbuilder1 = workpart.Features.CreateCylinderBuilder(null);
Axis theaxis = cylinderbuilder1.Axis;
theaxis.Direction = thedirection;
theaxis.Point = thepoint;
cylinderbuilder1.Diameter.RightHandSide = diameter.ToString();
cylinderbuilder1.Height.RightHandSide = height.ToString();
cylinderbuilder1.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
theCylinder1 = (NXOpen.Features.Cylinder)cylinderbuilder1.Commit();
cylinderbuilder1.Destroy();

// EdgeBlendBuilder

Part workPart = s.Parts.Work;
NXOpen.Features.Feature nullNXOpen_Features_Feature = null;
NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1;
edgeBlendBuilder1 = workpart.Features.CreateEdgeBlendBuilder(nullNXOpen_Features_Feature);

NXOpen.ScCollector scCollector1;
scCollector1 = workpart.ScCollectors.CreateCollector();

Cylinder cyl = theCylinder1;
Edge[] edges = cyl.GetEdges();
int index = 0;
Edge edge1 = edges[index];

NXOpen.Edge[] seedEdges1 = new NXOpen.Edge[1];
seedEdges1[0] = edge1;


NXOpen.Point3d origin1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
NXOpen.Vector3d vector1 = new NXOpen.Vector3d(1.0, 0.0, 0.0);
NXOpen.Direction direction1 = null;
direction1 = workpart.Directions.CreateDirection(origin1, vector1, NXOpen.SmartObject.UpdateOption.WithinModeling);

NXOpen.EdgeMultipleSeedTangentRule edgeMultipleSeedTangentRule1;
edgeMultipleSeedTangentRule1 = workpart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, true);

NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
rules1[0] = edgeMultipleSeedTangentRule1;
scCollector1.ReplaceRules(rules1, false);

edgeBlendBuilder1.Tolerance = 0.01;

edgeBlendBuilder1.AllInstancesOption = false;

edgeBlendBuilder1.RemoveSelfIntersection = true;

edgeBlendBuilder1.PatchComplexGeometryAreas = true;

edgeBlendBuilder1.LimitFailingAreas = true;

edgeBlendBuilder1.ConvexConcaveY = false;

edgeBlendBuilder1.RollOverSmoothEdge = true;

edgeBlendBuilder1.RollOntoEdge = true;

edgeBlendBuilder1.MoveSharpEdge = true;

edgeBlendBuilder1.TrimmingOption = false;

edgeBlendBuilder1.OverlapOption = NXOpen.Features.EdgeBlendBuilder.Overlap.AnyConvexityRollOver;

edgeBlendBuilder1.BlendOrder = NXOpen.Features.EdgeBlendBuilder.OrderOfBlending.ConvexFirst;

edgeBlendBuilder1.SetbackOption = NXOpen.Features.EdgeBlendBuilder.Setback.SeparateFromCorner;

edgeBlendBuilder1.BlendFaceContinuity = NXOpen.Features.EdgeBlendBuilder.FaceContinuity.Tangent;

int csIndex1;
csIndex1 = edgeBlendBuilder1.AddChainset(scCollector1, radius.ToString());

NXOpen.Features.Feature feature1;
feature1 = edgeBlendBuilder1.CommitFeature();
edgeBlendBuilder1.Destroy();


}
public static void CreateSmallEdgeBlendCylinder()

{
double radius = 5.0;
double diameter = 30;
double height = 60;

Session s = Session.GetSession();
Part workpart = s.Parts.Work;
Point3d theorigin = new Point3d(70, 0, 0);
Point thepoint = workpart.Points.CreatePoint(theorigin);
Vector3d thevector = new Vector3d(1, 0, 0);
Direction thedirection = workpart.Directions.CreateDirection(theorigin, thevector, SmartObject.UpdateOption.WithinModeling);
CylinderBuilder cylinderbuilder1 = workpart.Features.CreateCylinderBuilder(null);
Axis theaxis = cylinderbuilder1.Axis;
theaxis.Direction = thedirection;
theaxis.Point = thepoint;
cylinderbuilder1.Diameter.RightHandSide = diameter.ToString();
cylinderbuilder1.Height.RightHandSide = height.ToString();
cylinderbuilder1.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
NXOpen.Features.Cylinder theCylinder = (NXOpen.Features.Cylinder)cylinderbuilder1.Commit();
cylinderbuilder1.Destroy();

// EdgeBlendBuilder

Part workPart = s.Parts.Work;
NXOpen.Features.Feature nullNXOpen_Features_Feature = null;
NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1;
edgeBlendBuilder1 = workpart.Features.CreateEdgeBlendBuilder(nullNXOpen_Features_Feature);

NXOpen.ScCollector scCollector1;
scCollector1 = workpart.ScCollectors.CreateCollector();

Cylinder cyl = theCylinder;
Edge[] edges = cyl.GetEdges();
int index1 = 0;
Edge edge1 = edges[index1];

NXOpen.Edge[] seedEdges1 = new NXOpen.Edge[1];
seedEdges1[0] = edge1;


NXOpen.Point3d origin1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
NXOpen.Vector3d vector1 = new NXOpen.Vector3d(1.0, 0.0, 0.0);
NXOpen.Direction direction1 = null;
direction1 = workpart.Directions.CreateDirection(origin1, vector1, NXOpen.SmartObject.UpdateOption.WithinModeling);

NXOpen.EdgeMultipleSeedTangentRule edgeMultipleSeedTangentRule1;
edgeMultipleSeedTangentRule1 = workpart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, true);

NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
rules1[0] = edgeMultipleSeedTangentRule1;
scCollector1.ReplaceRules(rules1, false);

edgeBlendBuilder1.Tolerance = 0.01;

edgeBlendBuilder1.AllInstancesOption = false;

edgeBlendBuilder1.RemoveSelfIntersection = true;

edgeBlendBuilder1.PatchComplexGeometryAreas = true;

edgeBlendBuilder1.LimitFailingAreas = true;

edgeBlendBuilder1.ConvexConcaveY = false;

edgeBlendBuilder1.RollOverSmoothEdge = true;

edgeBlendBuilder1.RollOntoEdge = true;

edgeBlendBuilder1.MoveSharpEdge = true;

edgeBlendBuilder1.TrimmingOption = false;

edgeBlendBuilder1.OverlapOption = NXOpen.Features.EdgeBlendBuilder.Overlap.AnyConvexityRollOver;

edgeBlendBuilder1.BlendOrder = NXOpen.Features.EdgeBlendBuilder.OrderOfBlending.ConvexFirst;

edgeBlendBuilder1.SetbackOption = NXOpen.Features.EdgeBlendBuilder.Setback.SeparateFromCorner;

edgeBlendBuilder1.BlendFaceContinuity = NXOpen.Features.EdgeBlendBuilder.FaceContinuity.Tangent;

int csIndex1;
csIndex1 = edgeBlendBuilder1.AddChainset(scCollector1, radius.ToString());

NXOpen.Features.Feature feature1;
feature1 = edgeBlendBuilder1.CommitFeature();
edgeBlendBuilder1.Destroy();

NXOpen.Features.BodyFeature union22 = (NXOpen.Features.BodyFeature)theCylinder1;
Body[] thebodies22 = union22.GetBodies();
Body thebody22 = thebodies22[0];


NXOpen.Features.BodyFeature ebcylinder = (NXOpen.Features.BodyFeature)theCylinder;
Body[] thebodies2 = ebcylinder.GetBodies();
Body thebody2 = thebodies2[0];
BooleanFeature union = NXOpen.Guide.Unite(thebody22, thebody2);


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

23 REPLIES 23

Re: Edge Blend and 2 unite cylinder

Legend
Legend

@Krishna11 

 

Because NXopen API internally uses a loop to find the edges. We cant find which edge may come in a zeroth index. 

 

Now, We need to filter the edge based on some logic. In this case, I may use to find the distance between the edge and that CSYS or try to find face normal. I am not sure which may work. Once we freeze a logic, We can start implementing it. 

 

 

伊尔凡

Re: Edge Blend and 2 unite cylinder

Builder
Builder
@Irfan23
Yes Sir,Your logic is correct.
how could it be implemented in code?
Is there any way/hint?
Thank You

Re: Edge Blend and 2 unite cylinder

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Assuming the API program creates the cylinder(s), YOU need to come up with the logic.

Is it the one closer to the ABS zero?

The one further away?

Closest to the cylinder's "origin point"?
Furthest away?

"Smaller" value along cylinder axis?

"Larger" value along cylinder axis?

The one closer to the "smaller" cylinder?

etc. etc.

 

We don't really know your design intent.  Without the design intent, we cannot define the logic required.

 

 

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


Re: Edge Blend and 2 unite cylinder

Builder
Builder
@Ken_A
Hello Sir,
I have no specific design intent.
It would be nice if it could be possible by following ways
"Smaller" value along cylinder axis?
"Larger" value along cylinder axis?
The one closer to the "smaller" cylinder?

And if not possible,
You could adopt any other way .
Thank You

Re: Edge Blend and 2 unite cylinder

Builder
Builder

Hello Sir,

Any solution to this.

I tried various ways but could not succeed.

Please kindly help.

 

Thank You 

Re: Edge Blend and 2 unite cylinder

Builder
Builder

Hello Everyone,

Any solution to this problem?

How to solve this?

Re: Edge Blend and 2 unite cylinder

Builder
Builder

Hello Everyone,

please any solution this problem.

Any snippest of code?

Any journal?

Re: Edge Blend and 2 unite cylinder

Siemens Phenom Siemens Phenom
Siemens Phenom

The cylinder has two edges. They are both circular. Read the centers of the circles, and use this center information to decide which edge you want to blend. Pass this edge to the blending function.

山田
yamada

Re: Edge Blend and 2 unite cylinder

Builder
Builder
Hello Sir,
Main problem is in following snippet of a code.

Cylinder cyl = theCylinder;
Edge[] edges = cyl.GetEdges();
int index1 = 0;
Edge edge1 = edges[index1];

NXOpen.Edge[] seedEdges1 = new NXOpen.Edge[1];
seedEdges1[0] = edge1;

If I put int index1 = 0 or 1 still shifting of edge is taking place.
How to solve this problem?