Esempio n. 1
0
        public static void CurveAndBsplineCurve(string unparsed)
        {
            Application app = Utilities.ComApp;

            Point3d[] pntArray = new Point3d[5];
            pntArray[0] = app.Point3dFromXY(0, -19);
            pntArray[1] = app.Point3dFromXY(1, -17);
            pntArray[2] = app.Point3dFromXY(2, -19);
            pntArray[3] = app.Point3dFromXY(3, -17);
            pntArray[4] = app.Point3dFromXY(4, -19);
            CurveElement oCurve = app.CreateCurveElement1(null, ref pntArray);

            oCurve.Color      = 0;
            oCurve.LineWeight = 2;
            app.ActiveModelReference.AddElement(oCurve);
            for (int i = 0; i < 5; i++)
            {
                pntArray[i].X += 5;
            }

            InterpolationCurve oInterpolationCurve = new InterpolationCurveClass();

            oInterpolationCurve.SetFitPoints(pntArray);
            BsplineCurveElement oBsplineCurve = app.CreateBsplineCurveElement2(null, oInterpolationCurve);

            oBsplineCurve.Color      = 1;
            oBsplineCurve.LineWeight = 2;
            app.ActiveModelReference.AddElement(oBsplineCurve);
        }
Esempio n. 2
0
        public static void ConeAndBsplineSurface()
        {
            Application app     = Utilities.ComApp;
            Point3d     basePt  = app.Point3dFromXYZ(2, -23, 0);
            Point3d     topPt   = app.Point3dFromXYZ(2, -20, 0);
            Matrix3d    rMatrix = app.Matrix3dFromAxisAndRotationAngle(0, app.Pi() / 6);
            ConeElement oCone   = app.CreateConeElement1(null, 2, ref basePt, 1, ref topPt, ref rMatrix);

            oCone.Color = 0;
            app.ActiveModelReference.AddElement(oCone);

            Point3d[]          aFitPnts  = new Point3d[4];
            InterpolationCurve oFitCurve = new InterpolationCurveClass();

            BsplineCurve[] aCurves = new BsplineCurve[3];

            aFitPnts[0] = app.Point3dFromXYZ(5.9, -21, -0.5);
            aFitPnts[1] = app.Point3dFromXYZ(6.9, -20, 1);
            aFitPnts[2] = app.Point3dFromXYZ(7.9, -20.3, 1.3);
            aFitPnts[3] = app.Point3dFromXYZ(8.9, -20.8, 0.3);
            oFitCurve.SetFitPoints(ref aFitPnts);
            oFitCurve.BesselTangents = true;
            aCurves[0] = new BsplineCurveClass();
            aCurves[0].FromInterpolationCurve(oFitCurve);

            aFitPnts[0] = app.Point3dFromXYZ(6.4, -22, 0);
            aFitPnts[1] = app.Point3dFromXYZ(7.1, -21.2, 0.7);
            aFitPnts[2] = app.Point3dFromXYZ(7.7, -21, 1);
            aFitPnts[3] = app.Point3dFromXYZ(8.4, -21.7, -0.2);
            oFitCurve.SetFitPoints(ref aFitPnts);
            oFitCurve.BesselTangents = true;
            aCurves[1] = new BsplineCurveClass();
            aCurves[1].FromInterpolationCurve(oFitCurve);

            aFitPnts[0] = app.Point3dFromXYZ(5.9, -23, 0);
            aFitPnts[1] = app.Point3dFromXYZ(7.2, -23.1, 1.2);
            aFitPnts[2] = app.Point3dFromXYZ(7.8, -23.3, 0.8);
            aFitPnts[3] = app.Point3dFromXYZ(8.7, -22.8, 0.2);
            oFitCurve.SetFitPoints(ref aFitPnts);
            oFitCurve.BesselTangents = true;
            aCurves[2] = new BsplineCurveClass();
            aCurves[2].FromInterpolationCurve(oFitCurve);

            BsplineSurface oBsplineSurface = new BsplineSurfaceClass();

            oBsplineSurface.FromCrossSections(ref aCurves, MsdBsplineSurfaceDirection.V, 4, true, true);
            BsplineSurfaceElement oSurfaceElm = app.CreateBsplineSurfaceElement1(null, oBsplineSurface);

            oSurfaceElm.Color = 1;
            app.ActiveModelReference.AddElement(oSurfaceElm);
        }