Beispiel #1
0
        public void SliceLineCommand()
        {
            Editor   editor   = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database arg_15_0 = HostApplicationServices.WorkingDatabase;

            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[] objectId_ = CommandLineQuerries.SelectLines(false);
                ngeometry.VectorGeometry.Plane planeNormalized = CommandLineQuerries.Specify3PSystem().GetPlaneNormalized();
                int num = 0;
                while (num == 0)
                {
                    Point             left = new Point();
                    PromptPointResult promptPointResult = CommandLineQuerries.SpecifyPointOrKeepBothSides();
                    if (promptPointResult.Status == (PromptStatus)(-5005))
                    {
                        num = 0;
IL_F2_:
                        this.method_0(objectId_, planeNormalized, num);
                        return;
                    }
                    if (promptPointResult.Status == (PromptStatus)5100)
                    {
                        Point3d value = promptPointResult.Value;
                        left = new Point(value.X, value.Y, value.Z);
                        num  = Math.Sign(ngeometry.VectorGeometry.Vector3d.Dot(planeNormalized.NormalVector, new ngeometry.VectorGeometry.Vector3d(left - planeNormalized.Point)));
                        if (num == 0)
                        {
                            editor.WriteMessage("\nInvalid point: point is on plane.");
                        }
                    }
                    else if (promptPointResult.Status == (PromptStatus)(-5002))
                    {
                        CommandLineQuerries.OnCancelled();
                    }
                    else if (promptPointResult.Status != (PromptStatus)5100)
                    {
                        CommandLineQuerries.OnNotOK();
                    }
                }
                goto IL_F2;
IL_F2:
                {
                    this.method_0(objectId_, planeNormalized, num);
                    return;
                }
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine);
            }
        }
        public void DevelopmentCommand()
        {
            Database arg_05_0 = HostApplicationServices.WorkingDatabase;
            Editor   editor   = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                PromptEntityOptions promptEntityOptions = new PromptEntityOptions("Select polyline");
                promptEntityOptions.SetRejectMessage("\nNo polyline selected");
                promptEntityOptions.AddAllowedClass(typeof(Polyline3d), true);
                promptEntityOptions.AddAllowedClass(typeof(Polyline2d), true);
                promptEntityOptions.AddAllowedClass(typeof(Polyline), true);
                promptEntityOptions.AllowNone = (false);
                PromptEntityResult entity = editor.GetEntity(promptEntityOptions);
                if (entity.Status == (PromptStatus)(-5002))
                {
                    CommandLineQuerries.OnCancelled();
                }
                if (entity.Status != (PromptStatus)5100)
                {
                    CommandLineQuerries.OnNotOK();
                }
                CMD_Development.string_2 = CommandLineQuerries.KeywordYesNo("Reverse polyline", CMD_Development.string_2, false, false);
                CMD_Development.string_3 = CommandLineQuerries.KeywordYesNo("Specify range", CMD_Development.string_3, false, false);
                if (CMD_Development.string_3 == "Y")
                {
                    CMD_Development.double_0 = CommandLineQuerries.SpecifyDouble("Specify start arc length", CMD_Development.double_0, false, false, false, true);
                    CMD_Development.double_1 = CommandLineQuerries.SpecifyDouble("Specify end arc length", CMD_Development.double_1, false, false, false, true);
                }
                CMD_Development.double_2 = CommandLineQuerries.SpecifyDouble("Specify z-scaling", CMD_Development.double_2, false, false, false, false);
                CMD_Development.string_5 = CommandLineQuerries.KeywordYesNo("Include first derivative (slope)", CMD_Development.string_5, false, false);
                if (CMD_Development.string_5 == "Y")
                {
                    CMD_Development.double_3 = CommandLineQuerries.SpecifyDouble("Specify z-scaling for derivative", CMD_Development.double_3, false, false, false, false);
                }
                CMD_Development.string_4 = CommandLineQuerries.SpecifyOutfileType(CMD_Development.string_4);
                CommandLineQuerries.SpecifyFileNameForWrite(ref CMD_Development.string_0, ref CMD_Development.string_1, CMD_Development.string_4);
                bool   reverse  = CMD_Development.string_2 == "Y";
                double startBGL = 0.0;
                double endBGL   = 1.7976931348623157E+308;
                if (CMD_Development.string_3 == "Y")
                {
                    startBGL = CMD_Development.double_0;
                    endBGL   = CMD_Development.double_1;
                }
                List <Point> list   = this.DevelopPolyline(entity.ObjectId, reverse, startBGL, endBGL);
                List <Point> points = new List <Point>();
                if (CMD_Development.string_5 == "Y")
                {
                    points = this.Derivative(list);
                }
                CMD_Development.Result result = new CMD_Development.Result(list, startBGL);
                editor.WriteMessage("\n" + result.ToString());
                Database database = new Database(true, true);
                using (Transaction transaction = database.TransactionManager.StartTransaction())
                {
                    BlockTable        blockTable        = (BlockTable)transaction.GetObject(database.BlockTableId, (OpenMode)1);
                    BlockTableRecord  blockTableRecord  = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                    bool              flag              = false;
                    ObjectId          layerId           = DBManager.CreateLayer("profile", 7, false, ref flag, database);
                    Point3dCollection point3dCollection = Conversions.ToPoint3dCollection(list);
                    Polyline3d        polyline3d        = new Polyline3d(0, point3dCollection, false);
                    point3dCollection.Dispose();
                    polyline3d.LayerId = (layerId);
                    blockTableRecord.AppendEntity(polyline3d);
                    transaction.AddNewlyCreatedDBObject(polyline3d, true);
                    if (CMD_Development.string_5 == "Y")
                    {
                        bool              flag2              = false;
                        ObjectId          layerId2           = DBManager.CreateLayer("slope", 4, false, ref flag2, database);
                        Point3dCollection point3dCollection2 = Conversions.ToPoint3dCollection(points);
                        Polyline3d        polyline3d2        = new Polyline3d(0, point3dCollection2, false);
                        point3dCollection2.Dispose();
                        polyline3d2.LayerId = (layerId2);
                        blockTableRecord.AppendEntity(polyline3d2);
                        transaction.AddNewlyCreatedDBObject(polyline3d2, true);
                    }
                    transaction.Commit();
                    polyline3d.Dispose();
                }
                DBManager.SaveDrawing(database, CMD_Development.string_0, CMD_Development.string_4, (DwgVersion)29);
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine);
            }
        }
Beispiel #3
0
        public void SliceFacesCommand()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[]       objectId_        = CommandLineQuerries.SelectFaces(false);
                CoordinateSystem coordinateSystem = CommandLineQuerries.Specify3PSystem();
                ngeometry.VectorGeometry.Plane planeNormalized = coordinateSystem.GetPlaneNormalized();
                int num = 0;
                while (num == 0)
                {
                    Point             left = new Point();
                    PromptPointResult promptPointResult = CommandLineQuerries.SpecifyPointOrKeepBothSides();
                    if (promptPointResult.Status == (PromptStatus)(-5005))
                    {
                        num = 0;
IL_F3_:
                        EntitySlicer.string_0 = CommandLineQuerries.KeywordYesNo("Keep coplanar faces", EntitySlicer.string_0, false, false);
                        int  num2  = 0;
                        int  num3  = 0;
                        int  num4  = 0;
                        bool bool_ = false;
                        if (EntitySlicer.string_0.Trim().ToUpper() == "Y")
                        {
                            bool_ = true;
                        }
                        this.method_1(objectId_, planeNormalized, num, bool_, ref num2, ref num3, ref num4);
                        editor.WriteMessage("\nFailed faces   : " + num3.ToString());
                        editor.WriteMessage("\nFaces sliced   : " + num2.ToString());
                        editor.WriteMessage("\nFaces remaining: " + num4.ToString());
                        return;
                    }
                    if (promptPointResult.Status == (PromptStatus)5100)
                    {
                        Point3d value = promptPointResult.Value;
                        left = new Point(value.X, value.Y, value.Z);
                        num  = Math.Sign(ngeometry.VectorGeometry.Vector3d.Dot(planeNormalized.NormalVector, new ngeometry.VectorGeometry.Vector3d(left - planeNormalized.Point)));
                        if (num == 0)
                        {
                            editor.WriteMessage("\nInvalid point: point is on slicing plane.");
                        }
                    }
                    else if (promptPointResult.Status == (PromptStatus)(-5002))
                    {
                        CommandLineQuerries.OnCancelled();
                    }
                    else if (promptPointResult.Status != (PromptStatus)5100)
                    {
                        CommandLineQuerries.OnNotOK();
                    }
                }
                goto IL_F3;
IL_F3:
                {
                    EntitySlicer.string_0 = CommandLineQuerries.KeywordYesNo("Keep coplanar faces", EntitySlicer.string_0, false, false);
                    int  num2  = 0;
                    int  num3  = 0;
                    int  num4  = 0;
                    bool bool_ = false;
                    if (EntitySlicer.string_0.Trim().ToUpper() == "Y")
                    {
                        bool_ = true;
                    }
                    this.method_1(objectId_, planeNormalized, num, bool_, ref num2, ref num3, ref num4);
                    editor.WriteMessage("\nFailed faces   : " + num3.ToString());
                    editor.WriteMessage("\nFaces sliced   : " + num2.ToString());
                    editor.WriteMessage("\nFaces remaining: " + num4.ToString());
                    return;
                }
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message + "\n");
            }
        }