CS_NXOpen_0002_Creating2Cylinder



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NXCylinder
{
    public class Class1
    {
        public static void Main(string[] args)
        {
            NXOpen.Session theSession = NXOpen.Session.GetSession();
            NXOpen.Part workPart = theSession.Parts.Work;
            NXOpen.Part displayPart = theSession.Parts.Display;

            // ----------------------------------------------
            //   Menu: Insert->Design Feature->Cylinder...
            // ----------------------------------------------
           

           // Creating First Cylinder

            NXOpen.Features.Feature nullNXOpen_Features_Feature = null;
            NXOpen.Features.CylinderBuilder cylinderBuilder1;

            cylinderBuilder1 = workPart.Features.CreateCylinderBuilder(nullNXOpen_Features_Feature);

            cylinderBuilder1.Diameter.RightHandSide = "200";

            cylinderBuilder1.Height.RightHandSide = "20";

           
            NXOpen.Axis axis1;
            axis1 = cylinderBuilder1.Axis;

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

            axis1.Direction = direction1;



            NXOpen.Point3d coordinates5 = new NXOpen.Point3d(100.0, 100.0, 100.0);
            NXOpen.Point point5;
            point5 = workPart.Points.CreatePoint(coordinates5);



            NXOpen.Point point6;
            point6 = axis1.Point;

            axis1.Point = point5;


            NXOpen.NXObject nXObject1;
            nXObject1 = cylinderBuilder1.Commit();

          


            // Creating second cylinder


            NXOpen.Features.CylinderBuilder cylinderBuilder2;

            cylinderBuilder2 = workPart.Features.CreateCylinderBuilder(nullNXOpen_Features_Feature);

            cylinderBuilder2.Diameter.RightHandSide = "20";

            cylinderBuilder2.Height.RightHandSide = "100";



            NXOpen.Axis axis2;
            axis2 = cylinderBuilder2.Axis;


          
            NXOpen.Vector3d vector2 = new NXOpen.Vector3d(1.0, 0.0, 0.0);
            NXOpen.Direction direction2;
            direction2 = workPart.Directions.CreateDirection(origin1, vector2, NXOpen.SmartObject.UpdateOption.WithinModeling);

            axis2.Direction = direction2;



            NXOpen.Point3d coordinates52 = new NXOpen.Point3d(100.0, 120.0, 100.0);
            NXOpen.Point point52;
            point52 = workPart.Points.CreatePoint(coordinates52);



            NXOpen.Point point62;
            point62 = axis2.Point;

            axis2.Point = point52;




            NXOpen.NXObject nXObject2;
            nXObject2 = cylinderBuilder2.Commit();

            cylinderBuilder1.Destroy();
            cylinderBuilder2.Destroy();

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

Comments

Popular posts from this blog

CS_NXOpen_0011_MoveBodies2Components

CS_NXOpen_0003_ProjectCurve

CS_NXOpen_0010_ExtrudeCurves