Kishor khalane
Mechanical
- Jul 27, 2018
- 9
Hi, Guys
Following code is hard coded.
I want that the inputs should be given by user..
Cylinder EdgeBlend COde
using System;
using NXOpen;
class NXJournal
{
public static void Main(string[] args)
{
Session theSession = Session.GetSession();
Part workPart = theSession.Parts.Work;
Part 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 = "20";
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
NXObject cylinder = cylinderbuilder.Commit();
cylinderbuilder.Destroy();
// edge blend builder
NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1;
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(null);
NXOpen.GeometricUtilities.BlendLimitsData blendLimitsData1;
blendLimitsData1 = edgeBlendBuilder1.LimitsListData;
NXOpen.Point3d origin2 = new NXOpen.Point3d(0.0, 0.0, 0.0);
NXOpen.Vector3d normal1 = new NXOpen.Vector3d(0.0, 0.0, 1.0);
NXOpen.Plane plane1;
plane1 = workPart.Planes.CreatePlane(origin2, normal1, NXOpen.SmartObject.UpdateOption.WithinModeling);
NXOpen.GeometricUtilities.FacePlaneSelectionBuilder facePlaneSelectionBuilder1;
facePlaneSelectionBuilder1 = workPart.FacePlaneSelectionBuilderData.Create();
NXOpen.ScCollector scCollector1;
scCollector1 = workPart.ScCollectors.CreateCollector();
NXOpen.Edge[] seedEdges1 = new NXOpen.Edge[1];
NXOpen.Features.Cylinder cylinder1 = (NXOpen.Features.Cylinder)cylinder;
NXOpen.Edge edge1 = (NXOpen.Edge)cylinder1.FindObject("EDGE * 1 * 3 {(100,-21.650635094611,12.5)(100,0,-25)(100,21.650635094611,12.5) CYLINDER(1)}");
seedEdges1[0] = edge1;
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, "3");
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; }
}
Following code is hard coded.
I want that the inputs should be given by user..
Cylinder EdgeBlend COde
using System;
using NXOpen;
class NXJournal
{
public static void Main(string[] args)
{
Session theSession = Session.GetSession();
Part workPart = theSession.Parts.Work;
Part 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 = "20";
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
NXObject cylinder = cylinderbuilder.Commit();
cylinderbuilder.Destroy();
// edge blend builder
NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1;
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(null);
NXOpen.GeometricUtilities.BlendLimitsData blendLimitsData1;
blendLimitsData1 = edgeBlendBuilder1.LimitsListData;
NXOpen.Point3d origin2 = new NXOpen.Point3d(0.0, 0.0, 0.0);
NXOpen.Vector3d normal1 = new NXOpen.Vector3d(0.0, 0.0, 1.0);
NXOpen.Plane plane1;
plane1 = workPart.Planes.CreatePlane(origin2, normal1, NXOpen.SmartObject.UpdateOption.WithinModeling);
NXOpen.GeometricUtilities.FacePlaneSelectionBuilder facePlaneSelectionBuilder1;
facePlaneSelectionBuilder1 = workPart.FacePlaneSelectionBuilderData.Create();
NXOpen.ScCollector scCollector1;
scCollector1 = workPart.ScCollectors.CreateCollector();
NXOpen.Edge[] seedEdges1 = new NXOpen.Edge[1];
NXOpen.Features.Cylinder cylinder1 = (NXOpen.Features.Cylinder)cylinder;
NXOpen.Edge edge1 = (NXOpen.Edge)cylinder1.FindObject("EDGE * 1 * 3 {(100,-21.650635094611,12.5)(100,0,-25)(100,21.650635094611,12.5) CYLINDER(1)}");
seedEdges1[0] = edge1;
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, "3");
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; }
}