Kishor khalane
Mechanical
- Jul 27, 2018
- 9
Hello Guys,
Below is the code for two cylinder in C#. Please tell how to UNITE this 2 cylinder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NXOpen;
namespace cylinderbuilder
{
public class Class1
{
public static void Main()
{
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();
// Another Cylinder
NXOpen.Features.CylinderBuilder cylinderbuilder1;
cylinderbuilder1 = workPart.Features.CreateCylinderBuilder(null);
// Specify the cylinder definition type(AxisDiameterAndHeight)
cylinderbuilder1.Type = NXOpen.Features.CylinderBuilder.Types.AxisDiameterAndHeight;
// Define the Cylinder Axis
Point3d origin1 = new Point3d(20, 0, 0);
Vector3d vector1 = new Vector3d(1, 0, 0);
Direction direction1;
direction1 = workPart.Directions.CreateDirection(origin1, vector1, SmartObject.UpdateOption.WithinModeling);
Axis axis1;
axis1 = cylinderbuilder1.Axis;
axis1.Direction = direction1;
// Define Cylinder Diameter
string diamString1 = "110";
cylinderbuilder1.Diameter.RightHandSide = diamString1;
// Define Cylinder Height
string heightString1 = "30";
cylinderbuilder1.Height.RightHandSide = heightString1;
// Define the boolean option (Create, unite, etc.)
cylinderbuilder1.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
// Destroy the builder to free memory
NXObject cylinder1 = cylinderbuilder1.Commit();
cylinderbuilder1.Destroy();
}
public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.Immediately; }
}
}
Below is the code for two cylinder in C#. Please tell how to UNITE this 2 cylinder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NXOpen;
namespace cylinderbuilder
{
public class Class1
{
public static void Main()
{
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();
// Another Cylinder
NXOpen.Features.CylinderBuilder cylinderbuilder1;
cylinderbuilder1 = workPart.Features.CreateCylinderBuilder(null);
// Specify the cylinder definition type(AxisDiameterAndHeight)
cylinderbuilder1.Type = NXOpen.Features.CylinderBuilder.Types.AxisDiameterAndHeight;
// Define the Cylinder Axis
Point3d origin1 = new Point3d(20, 0, 0);
Vector3d vector1 = new Vector3d(1, 0, 0);
Direction direction1;
direction1 = workPart.Directions.CreateDirection(origin1, vector1, SmartObject.UpdateOption.WithinModeling);
Axis axis1;
axis1 = cylinderbuilder1.Axis;
axis1.Direction = direction1;
// Define Cylinder Diameter
string diamString1 = "110";
cylinderbuilder1.Diameter.RightHandSide = diamString1;
// Define Cylinder Height
string heightString1 = "30";
cylinderbuilder1.Height.RightHandSide = heightString1;
// Define the boolean option (Create, unite, etc.)
cylinderbuilder1.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
// Destroy the builder to free memory
NXObject cylinder1 = cylinderbuilder1.Commit();
cylinderbuilder1.Destroy();
}
public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.Immediately; }
}
}