Cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Edge Blend and 2 unite cylinder

Builder
Builder
@cowski1
Helllo Sir,
I had already used in my code as shown above.
See this below

if (arc_data.radius == radius1 && arc_data.center[0] == distx3V1)

this distx3V1 is my X-coordinate that is this one [arc_data.center(0)]
But still I am getting difficulty.
How to solve?
Highlighted

Re: Edge Blend and 2 unite cylinder

Siemens Phenom Siemens Phenom
Siemens Phenom

I don't know if this is the only cause of your troubles, but ...

 

A test like arc_data.radius == radius1 or  arc_data.center[0] == distx3V1 will often fail. 

 

You should never compare floating point numbers using "==".

 

To test that two floating-point numbers a and b are equal, you should write a test like

if( System.Math.Abs(a-b) ) < tolerance, where tolerance is some small number, like 0.000001.

山田
yamada

Re: Edge Blend and 2 unite cylinder

Builder
Builder
Hello Sir,
Below is the whole code that I am going through.
I am getting front edge of first 2 cylinder but not the third cylinder.

using System;
using NXOpen;
using NXOpen.Features;
using NXOpen.UF;

namespace EDGEBlendR
{
public class CreateEdge
{

public static Session theSession;
public static UFSession theUFSession;
public static Part workPart;
public static Part Displaypart;
public static Cylinder cylinder;
public static Cylinder cylinder2;
public static Cylinder cylinder3;
public static BooleanFeature union;
public static void Main()
{
Cylinder1();
Cylinder2();
Cylinder3(); / /not getting edge blend of this cylinder.
}
public static void Cylinder1()
{
theSession = Session.GetSession();
theUFSession = UFSession.GetUFSession();
workPart = theSession.Parts.Work;
Displaypart = theSession.Parts.Display;

NXOpen.Features.CylinderBuilder cylinderbuilder;
cylinderbuilder = workPart.Features.CreateCylinderBuilder(null);

// Specify the cylinder definition type(AxisDiameterAndHeight)
cylinderbuilder.Type = NXOpen.Features.CylinderBuilder.Types.AxisDiameterAndHeight;

// Define the Cylinder Axis
Point3d origin = new Point3d(0, 0, 0);
Vector3d vector = new Vector3d(1, 0, 0);
Direction direction;
direction = workPart.Directions.CreateDirection(origin, vector, SmartObject.UpdateOption.WithinModeling);
Axis axis;
axis = cylinderbuilder.Axis;
axis.Direction = direction;

// Define Cylinder Diameter
string diamString = "100";
cylinderbuilder.Diameter.RightHandSide = diamString;

// Define Cylinder Height
string heightString = "50";
cylinderbuilder.Height.RightHandSide = heightString;

// Define the boolean option (Create, unite, etc.)
cylinderbuilder.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;

// Destroy the builder to free memory
cylinder = (NXOpen.Features.Cylinder)cylinderbuilder.Commit();
cylinderbuilder.Destroy();

Cylinder cy = (Cylinder)cylinder;
foreach (Edge objEdge in cy.GetEdges())
{
IntPtr arc_evaluator;
theUFSession.Eval.Initialize(objEdge.Tag, out arc_evaluator);
UFEval.Arc arc_data;
theUFSession.Eval.AskArc(arc_evaluator, out arc_data);
if (arc_data.radius == 50 && arc_data.center[0] == 50)
{

CreateEdgeBlend1(objEdge, 10.0);

}
}
}

public static void CreateEdgeBlend1(Edge objEdge, double radius)
{
theSession = Session.GetSession();
workPart = theSession.Parts.Work;
Displaypart = theSession.Parts.Display;

NXOpen.Features.Feature nullNXOpen_Features_Feature = null;
NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1;
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullNXOpen_Features_Feature);

NXOpen.Unit unit1 = (NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter");
NXOpen.Expression expression1;
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Expression expression2;
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.GeometricUtilities.BlendLimitsData blendLimitsData1;
blendLimitsData1 = edgeBlendBuilder1.LimitsListData;

NXOpen.GeometricUtilities.FacePlaneSelectionBuilder facePlaneSelectionBuilder1;
facePlaneSelectionBuilder1 = workPart.FacePlaneSelectionBuilderData.Create();

NXOpen.Expression expression3;
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Expression expression4;
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

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

NXOpen.Edge[] seedEdges1 = new NXOpen.Edge[1];
seedEdges1[0] = objEdge;
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);

NXOpen.Session.UndoMarkId markId2;
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Edge Blend");

theSession.DeleteUndoMark(markId2, null);

NXOpen.Session.UndoMarkId markId3;
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Edge Blend");

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();
workPart.FacePlaneSelectionBuilderData.Destroy(facePlaneSelectionBuilder1);

edgeBlendBuilder1.Destroy();
}

public static void Cylinder2()
{
theSession = Session.GetSession();
theUFSession = UFSession.GetUFSession();
workPart = theSession.Parts.Work;
Displaypart = theSession.Parts.Display;

NXOpen.Features.CylinderBuilder cylinderbuilder;
cylinderbuilder = workPart.Features.CreateCylinderBuilder(null);

// Specify the cylinder definition type(AxisDiameterAndHeight)
cylinderbuilder.Type = NXOpen.Features.CylinderBuilder.Types.AxisDiameterAndHeight;

// Define the Cylinder Axis
Point3d origin = new Point3d(50, 0, 0);
Point thepoint = workPart.Points.CreatePoint(origin);
Vector3d vector = new Vector3d(1, 0, 0);
Direction direction;
direction = workPart.Directions.CreateDirection(origin, vector, SmartObject.UpdateOption.WithinModeling);
Axis axis;
axis = cylinderbuilder.Axis;
axis.Direction = direction;
axis.Point = thepoint;

// Define Cylinder Diameter
string diamString = "60";
cylinderbuilder.Diameter.RightHandSide = diamString;

// Define Cylinder Height
string heightString = "50";
cylinderbuilder.Height.RightHandSide = heightString;

// Define the boolean option (Create, unite, etc.)
cylinderbuilder.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;

// Destroy the builder to free memory
cylinder2 = (NXOpen.Features.Cylinder)cylinderbuilder.Commit();
cylinderbuilder.Destroy();

Cylinder cyl = (Cylinder)cylinder2;
foreach (Edge objEdge in cyl.GetEdges())
{
IntPtr arc_evaluator;
theUFSession.Eval.Initialize(objEdge.Tag, out arc_evaluator);
UFEval.Arc arc_data;
theUFSession.Eval.AskArc(arc_evaluator, out arc_data);
if (arc_data.radius == 30 && arc_data.center[0] == 100)
{

CreateEdgeBlend2(objEdge, 5.0);

}
}


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


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

public static void CreateEdgeBlend2(Edge objEdge, double radius)
{
theSession = Session.GetSession();
workPart = theSession.Parts.Work;
Displaypart = theSession.Parts.Display;

NXOpen.Features.Feature nullNXOpen_Features_Feature = null;
NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1;
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullNXOpen_Features_Feature);

NXOpen.Unit unit1 = (NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter");
NXOpen.Expression expression1;
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Expression expression2;
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.GeometricUtilities.BlendLimitsData blendLimitsData1;
blendLimitsData1 = edgeBlendBuilder1.LimitsListData;

NXOpen.GeometricUtilities.FacePlaneSelectionBuilder facePlaneSelectionBuilder1;
facePlaneSelectionBuilder1 = workPart.FacePlaneSelectionBuilderData.Create();

NXOpen.Expression expression3;
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Expression expression4;
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

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

NXOpen.Edge[] seedEdges1 = new NXOpen.Edge[1];
seedEdges1[0] = objEdge;
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);

NXOpen.Session.UndoMarkId markId2;
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Edge Blend");

theSession.DeleteUndoMark(markId2, null);

NXOpen.Session.UndoMarkId markId3;
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Edge Blend");

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();
workPart.FacePlaneSelectionBuilderData.Destroy(facePlaneSelectionBuilder1);

edgeBlendBuilder1.Destroy();
}

public static void Cylinder3()
{
theSession = Session.GetSession();
theUFSession = UFSession.GetUFSession();
workPart = theSession.Parts.Work;
Displaypart = theSession.Parts.Display;

NXOpen.Features.CylinderBuilder cylinderbuilder;
cylinderbuilder = workPart.Features.CreateCylinderBuilder(null);

// Specify the cylinder definition type(AxisDiameterAndHeight)
cylinderbuilder.Type = NXOpen.Features.CylinderBuilder.Types.AxisDiameterAndHeight;

// Define the Cylinder Axis
Point3d origin = new Point3d(100, 0, 0);
Point thepoint = workPart.Points.CreatePoint(origin);
Vector3d vector = new Vector3d(1, 0, 0);
Direction direction;
direction = workPart.Directions.CreateDirection(origin, vector, SmartObject.UpdateOption.WithinModeling);
Axis axis;
axis = cylinderbuilder.Axis;
axis.Direction = direction;
axis.Point = thepoint;

// Define Cylinder Diameter
string diamString = "30";
cylinderbuilder.Diameter.RightHandSide = diamString;

// Define Cylinder Height
string heightString = "50";
cylinderbuilder.Height.RightHandSide = heightString;

// Define the boolean option (Create, unite, etc.)
cylinderbuilder.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;

// Destroy the builder to free memory
cylinder3 = (NXOpen.Features.Cylinder)cylinderbuilder.Commit();
cylinderbuilder.Destroy();

Cylinder cyl = (Cylinder)cylinder3;
foreach (Edge objEdge in cyl.GetEdges())
{
IntPtr arc_evaluator;
theUFSession.Eval.Initialize(objEdge.Tag, out arc_evaluator);
UFEval.Arc arc_data;
theUFSession.Eval.AskArc(arc_evaluator, out arc_data);
if (arc_data.radius == 15 && arc_data.center[0] == 150)
{

CreateEdgeBlend3(objEdge, 5.0);

}
}


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


//NXOpen.Features.BodyFeature ebcylinder = (NXOpen.Features.BodyFeature)cylinder2;
//Body[] thebodies2 = ebcylinder.GetBodies();
//Body thebody2 = thebodies2[0];
//BooleanFeature union1 = NXOpen.Guide.Unite(thebody22, thebody2);
}

public static void CreateEdgeBlend3(Edge objEdge, double radius)
{
theSession = Session.GetSession();
workPart = theSession.Parts.Work;
Displaypart = theSession.Parts.Display;

NXOpen.Features.Feature nullNXOpen_Features_Feature = null;
NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1;
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullNXOpen_Features_Feature);

NXOpen.Unit unit1 = (NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter");
NXOpen.Expression expression1;
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Expression expression2;
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.GeometricUtilities.BlendLimitsData blendLimitsData1;
blendLimitsData1 = edgeBlendBuilder1.LimitsListData;

NXOpen.GeometricUtilities.FacePlaneSelectionBuilder facePlaneSelectionBuilder1;
facePlaneSelectionBuilder1 = workPart.FacePlaneSelectionBuilderData.Create();

NXOpen.Expression expression3;
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Expression expression4;
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

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

NXOpen.Edge[] seedEdges1 = new NXOpen.Edge[1];
seedEdges1[0] = objEdge;
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);

NXOpen.Session.UndoMarkId markId2;
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Edge Blend");

theSession.DeleteUndoMark(markId2, null);

NXOpen.Session.UndoMarkId markId3;
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Edge Blend");

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();
workPart.FacePlaneSelectionBuilderData.Destroy(facePlaneSelectionBuilder1);

edgeBlendBuilder1.Destroy();
}

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

}

Re: Edge Blend and 2 unite cylinder

Builder
Builder

Hello Everyone,

Any solution/suggestions to above problem?