Exemplo n.º 1
0
 public static Snap.NX.Line Wrap(Tag nxopenLineTag)
 {
     if (nxopenLineTag == Tag.Null)
     {
         throw new ArgumentException("Input tag is NXOpen.Tag.Null");
     }
     NXOpen.Line objectFromTag = Snap.NX.NXObject.GetObjectFromTag(nxopenLineTag) as NXOpen.Line;
     if (objectFromTag == null)
     {
         throw new ArgumentException("Input tag doesn't belong to an NXOpen.Line object");
     }
     return(objectFromTag);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //Get the NX Open API
            Session theNXAutomationSession = Session.GetSession();
            // Get the NX Open API
            //NXOpen.UI theUI = UI.GetUI();
            //Get the UF Session using NX Open UF API
            UFSession theNXOpenNetSession = UFSession.GetUFSession();

            try
            {
                //Declartions
                string name;

                // Intilize the NX Open UF Session, This will not needed once UF
                // will get intilized in Session.
                //theNXOpenNetSession.UF.Initialize();

                //Create new part using NX Open UF API
                //string part_name = "CreateLine2";
                //int units =2;
                //theNXOpenNetSession.Part.New(part_name, units, out part);

                //Create New Part file using NX Open API
                NXOpen.Part myPart = theNXAutomationSession.Parts.NewDisplay("InteropNXOpenWithUFWrap", NXOpen.Part.Units.Millimeters);
                NXOpen.Tag  part   = myPart.Tag;
                //Query the part name using NX Open API
                theNXOpenNetSession.Part.AskPartName(part, out name);

                // Create Line using NX Open APIs
                NXOpen.Point3d point3d1 = new Point3d(-2.45197396411307, 3.58206319143819, 0);
                NXOpen.Point3d point3d2 = new Point3d(5.32514590979158, -1.0012853802839, 0);
                NXOpen.Line    line1    = theNXAutomationSession.Parts.Work.Curves.CreateLine(point3d1, point3d2);

                //Ask line data using NX Open UF API
                NXOpen.UF.UFCurve.Line line_coords;
                theNXOpenNetSession.Curve.AskLineData(line1.Tag, out line_coords);

                // Create Arc using NXOpen UF API
                NXOpen.Tag            arc, wcs;
                NXOpen.UF.UFCurve.Arc arc_coords = new NXOpen.UF.UFCurve.Arc();

                // Fill out the data structure
                arc_coords.start_angle   = 0.0;
                arc_coords.end_angle     = 3.0;
                arc_coords.arc_center    = new double[3];
                arc_coords.arc_center[0] = 0.0;
                arc_coords.arc_center[1] = 0.0;
                arc_coords.arc_center[2] = 1.0;
                arc_coords.radius        = 2.0;

                // Create a ARC using NXOpen UF API
                theNXOpenNetSession.Csys.AskWcs(out wcs);
                theNXOpenNetSession.Csys.AskMatrixOfObject(wcs, out arc_coords.matrix_tag);
                theNXOpenNetSession.Curve.CreateArc(ref arc_coords, out arc);

                // Create NX Open Arc Object using NXOpen UF arc Tag
                Arc NxArc = (Arc)NXOpen.Utilities.NXObjectManager.Get(arc);

                //Get the Arc parameters using NX Open APIs
                double         start_angle = NxArc.StartAngle;
                double         end_angle   = NxArc.EndAngle;
                NXOpen.Point3d arc_center  = NxArc.CenterPoint;

                // Save the Part using NXOpen UF API
                theNXOpenNetSession.Part.Save();
            }
            catch (NXException e)
            {
                Console.WriteLine("Exception is: {0}", e.Message);
            }
        }
Exemplo n.º 3
0
 internal Line(NXOpen.Line line) : base(line)
 {
     this.NXOpenLine = line;
 }