Example #1
0
        private UFCurve.Spline GetSplineData(Snap.NX.Spline mySpline)
        {
            Tag nXOpenTag = mySpline.NXOpenTag;

            UFCurve.Spline spline = new UFCurve.Spline();
            Globals.UFSession.Curve.AskSplineData(nXOpenTag, out spline);
            return(spline);
        }
Example #2
0
 public static Snap.NX.Spline[] Copy(Transform xform, params Snap.NX.Spline[] original)
 {
     Snap.NX.Spline[] splineArray = new Snap.NX.Spline[original.Length];
     for (int i = 0; i < original.Length; i++)
     {
         splineArray[i] = original[i].Copy(xform);
     }
     return(splineArray);
 }
Example #3
0
 private Snap.NX.Spline[] SplineArray(Snap.NX.Curve[] curveArray)
 {
     Snap.NX.Spline[] splineArray = new Snap.NX.Spline[curveArray.Length];
     for (int i = 0; i < curveArray.Length; i++)
     {
         splineArray[i] = (NXOpen.Spline)curveArray[i].NXOpenTaggedObject;
     }
     return(splineArray);
 }
Example #4
0
        private void SetSplineData(Snap.NX.Spline mySpline, UFCurve.Spline splineData)
        {
            Tag tag2;
            int num;

            UFCurve.State[] stateArray;
            Tag             nXOpenTag = mySpline.NXOpenTag;

            Globals.UFSession.Curve.CreateSpline(ref splineData, out tag2, out num, out stateArray);
            Tag[] tagArray  = new Tag[] { nXOpenTag };
            Tag[] tagArray2 = new Tag[] { tag2 };
            Globals.UFSession.Obj.ReplaceObjectArrayData(1, tagArray, tagArray2);
        }
Example #5
0
        public Snap.NX.Spline[] Divide()
        {
            Snap.NX.Spline     spline   = this.Copy();
            Snap.NX.Part       workPart = Globals.WorkPart;
            DivideCurveBuilder builder  = workPart.NXOpenPart.BaseFeatures.CreateDivideCurveBuilder(null);

            builder.Type            = DivideCurveBuilder.Types.AtKnotpoints;
            builder.KnotPointMethod = DivideCurveBuilder.KnotPointOption.AllKnotpoints;
            builder.DividingCurve.SetValue(spline.NXOpenCurve, workPart.NXOpenPart.Views.WorkView, (Point3d)spline.StartPoint);
            builder.Commit();
            NXOpen.NXObject[] committedObjects = builder.GetCommittedObjects();
            builder.Destroy();
            Snap.NX.Spline[] splineArray = new Snap.NX.Spline[committedObjects.Length];
            for (int i = 0; i < committedObjects.Length; i++)
            {
                NXOpen.NXObject obj1 = committedObjects[i];
                splineArray[i] = (NXOpen.Spline)committedObjects[i];
            }
            return(splineArray);
        }
Example #6
0
            private static Snap.NX.Arc SplineToArc(Snap.NX.Spline spline, double radius)
            {
                Vector vector = spline.Tangent(0.0);

                Snap.Position startPoint = spline.Position(0.0);
                Vector        vector2    = spline.Tangent(1.0);

                Snap.Position endPoint = spline.Position(1.0);
                double        num      = (double)(-vector * vector2);
                double        num2     = System.Math.Sqrt((1.0 - num) / 2.0);
                Vector        vector3  = Vector.Unit(vector - vector2);

                Snap.Position p            = (Snap.Position)(((startPoint + endPoint) / 2.0) + ((radius * (1.0 - num2)) * vector3));
                Snap.Position position4    = (Snap.Position)(p - ((Snap.Position)((2.0 * radius) * vector3)));
                Snap.Position q            = spline.Position(0.5);
                Snap.Position throughPoint = p;
                double        num3         = Snap.Position.Distance(p, q);

                if (Snap.Position.Distance(position4, q) < num3)
                {
                    throughPoint = position4;
                }
                return(Create.Arc(startPoint, throughPoint, endPoint));
            }