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

            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[] array = CommandLineQuerries.SelectPolylines(false);
                PLine.double_0 = CommandLineQuerries.SpecifyDouble("Specify epsilon range", PLine.double_0, false, false, false, true);
                PLine.string_2 = CommandLineQuerries.KeywordYesNo("Keep original polylines", PLine.string_2, false, false);
                int num  = 0;
                int num2 = 0;
                int num3 = 0;
                this.method_1(array, PLine.double_0, ref num, ref num2, ref num3);
                editor.WriteMessage(string.Concat(new string[]
                {
                    "\nNumber of vertices before    : ",
                    num.ToString(),
                    "\nNumber of vertices after     : ",
                    num2.ToString(),
                    "\nNumber of polylines processed: ",
                    array.Length.ToString(),
                    "\nNumber of polylines failed   : ",
                    num3.ToString()
                }));
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine);
            }
        }
示例#2
0
        public void GenerateSubDMeshCommand()
        {
            Database arg_05_0 = HostApplicationServices.WorkingDatabase;
            Editor   editor   = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                if (!Reg.Is2010OrHigher())
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("This method is supported only for version 2010 or higher.");
                }
                else
                {
                    ObjectId[] array = CommandLineQuerries.SelectFaces(false);
                    string     text  = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("SMOOTHMESHMAXFACE").ToString().Trim();
                    if (array.Length > Convert.ToInt32(text))
                    {
                        throw new InvalidOperationException(string.Concat(new object[]
                        {
                            "\nERROR: you have selected ",
                            array.Length.ToString(),
                            " faces while an allowable maximum of ",
                            text,
                            " is specified in the SMOOTHMESHMAXFACE system variable. Please set the SMOOTHMESHMAXFACE system variable at least to ",
                            array.Length,
                            " or select fewer faces."
                        }));
                    }
                    CMD_FacesToMesh.string_0 = CommandLineQuerries.KeywordYesNo("Delete original faces", CMD_FacesToMesh.string_0, false, false);
                    List <Triangle>         triangles = Conversions.ToCeometricAcDbTriangleList(array);
                    List <List <Triangle> > list      = this.method_0(triangles);
                    for (int i = 0; i < list.Count; i++)
                    {
                        SubDMeshHandler subDMeshHandler = new SubDMeshHandler(list[i]);
                        SubDMeshHandler.MeshGenerationResult meshGenerationResult = subDMeshHandler.GenerateSubDMesh();
                        editor.WriteMessage("\nMesh " + i.ToString().PadLeft(4) + ":\n" + meshGenerationResult.ToString());
                    }
                    if (CMD_FacesToMesh.string_0 == "Y")
                    {
                        DBManager.EraseObjects(array, 100000);
                    }
                }
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
        }
        public void GenerateSolidCommand()
        {
            ProgressMeter progressMeter = new ProgressMeter();
            Database      arg_0B_0      = HostApplicationServices.WorkingDatabase;
            Editor        editor        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            this.messageFilter_0 = new MessageFilter();
            System.Windows.Forms.Application.AddMessageFilter(this.messageFilter_0);
            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[] objectId_ = CommandLineQuerries.SelectFaces(false);
                CMD_FacesToSolid.string_1 = CommandLineQuerries.SpecifyReferencePlane(CMD_FacesToSolid.string_1);
                CoordinateSystem coordinateSystem = CoordinateSystem.Global();
                if (CMD_FacesToSolid.string_1 == "U")
                {
                    coordinateSystem = Conversions.GetUCS();
                }
                if (CMD_FacesToSolid.string_1 == "3P")
                {
                    coordinateSystem = CommandLineQuerries.Specify3PSystem();
                }
                coordinateSystem.Orthonormalize();
                CMD_FacesToSolid.double_0 = CommandLineQuerries.SpecifyDouble("Extrusion height in actual Z", CMD_FacesToSolid.double_0, false, true, false, false);
                bool flag = false;
                while (!flag)
                {
                    CMD_FacesToSolid.string_2 = CommandLineQuerries.SpecifyString("Minimum projected edge length", CMD_FacesToSolid.string_2, false);
                    if (Convert.ToDouble(CMD_FacesToSolid.string_2) >= 0.0001 && Convert.ToDouble(CMD_FacesToSolid.string_2) <= 1.0)
                    {
                        flag = true;
                    }
                    else
                    {
                        editor.WriteMessage("\nValue must be between 0.0001 and 1.");
                    }
                }
                CMD_FacesToSolid.string_0 = CommandLineQuerries.KeywordYesNo("Union solids", CMD_FacesToSolid.string_0, false, false).ToUpper().Trim();
                this.method_0(objectId_, progressMeter, coordinateSystem);
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                editor.WriteMessage("\n" + ex.Message);
            }
        }
示例#4
0
        public void LinesToPolylines()
        {
            Editor   editor   = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database arg_15_0 = HostApplicationServices.WorkingDatabase;

            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[] objectId_ = CommandLineQuerries.SelectLines(false);
                PLine.int_0    = CommandLineQuerries.SpecifyInteger("Specify number of relevant decimal digits", PLine.int_0, 0, 12, false, true);
                PLine.string_1 = CommandLineQuerries.KeywordYesNo("Eliminate zero length segments", PLine.string_1, false, false);
                PLine.string_0 = CommandLineQuerries.KeywordYesNo("Delete original lines", PLine.string_0, false, false);
                this.method_0(objectId_);
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
        }
示例#5
0
        public void LoadCommand()
        {
            Database arg_05_0 = HostApplicationServices.WorkingDatabase;
            Editor   editor   = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[]          objectIDs           = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.SOLID3D, "Select 3d solids", false);
                double              num                 = this.method_1(objectIDs);
                PromptDoubleOptions promptDoubleOptions = new PromptDoubleOptions("Maximum node spacing");
                promptDoubleOptions.DefaultValue = (num / 100.0);
                double   value    = editor.GetDouble(promptDoubleOptions).Value;
                string   text     = CommandLineQuerries.KeywordYesNo("Show generated nodes", "N", false, false);
                PointSet pointSet = this.method_0(objectIDs, value);
                editor.WriteMessage("\n" + pointSet.Count + " points generated on solids.");
                ConvexHull3d convexHull3d = new ConvexHull3d();
                convexHull3d.InitialPoints = pointSet;
                convexHull3d.ComputeHull();
                BoundingBox     boundingBox = convexHull3d.PrincipalAxesBoundingBox();
                List <Triangle> surface     = boundingBox.GetSurface();
                if (text.Trim().ToUpper() == "Y")
                {
                    DBManager.WriteListInDatabase <Point>(pointSet.ToList(), null, DBManager.EntityPropertiesAssignment.ByDialog, ObjectId.Null, ObjectId.Null);
                }
                DBManager.WriteListInDatabase <Triangle>(surface, null, DBManager.EntityPropertiesAssignment.ByDialog, ObjectId.Null, ObjectId.Null);
                editor.WriteMessage("\nPrincipal axes bounding box properties:");
                editor.WriteMessage("\n---------------------------------------");
                editor.WriteMessage("\nWidth              : " + boundingBox.Width.ToString(DBManager.GetFormatFromLUPREC()));
                editor.WriteMessage("\nLength             : " + boundingBox.Length.ToString(DBManager.GetFormatFromLUPREC()));
                editor.WriteMessage("\nHeight             : " + boundingBox.Height.ToString(DBManager.GetFormatFromLUPREC()));
                editor.WriteMessage("\nVolume             : " + boundingBox.Volume().ToString(DBManager.GetFormatFromLUPREC()));
                editor.WriteMessage("\nCenter             : " + boundingBox.CoordinateSystem.Origin.ToString());
                editor.WriteMessage("\nFirst basis vector : " + boundingBox.CoordinateSystem.BasisVector[0].ToString());
                editor.WriteMessage("\nSecond basis vector: " + boundingBox.CoordinateSystem.BasisVector[1].ToString());
                editor.WriteMessage("\nThird basis vector : " + boundingBox.CoordinateSystem.BasisVector[2].ToString());
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
        }
示例#6
0
        public void ProjectPointsCommand()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[] objectId_ = CommandLineQuerries.SelectFaces(true);
                PointProjection.string_0 = CommandLineQuerries.SpecifyRasterBySelectionOrByLayer(PointProjection.string_0);
                ObjectId[] array = null;
                if (PointProjection.string_0 == "S")
                {
                    array = CommandLineQuerries.SelectPoints(true);
                }
                else if (PointProjection.string_0 == "L")
                {
                    PointProjection.string_1 = CommandLineQuerries.SpecifyLayerName(PointProjection.string_1);
                    if (!DBManager.ExistsLayer(PointProjection.string_1))
                    {
                        throw new ArgumentException("Layer does not exist.");
                    }
                    array = DBManager.GetPointsOnLayer(PointProjection.string_1);
                    if (array == null)
                    {
                        throw new ArgumentException("No points selected.");
                    }
                    editor.WriteMessage(Environment.NewLine + array.Length + " points selected.");
                }
                PointProjection.string_4 = CommandLineQuerries.SpecifyProjectionDirection(PointProjection.string_4);
                ngeometry.VectorGeometry.Vector3d normalVector = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0);
                string a;
                if ((a = PointProjection.string_4.ToUpper()) != null)
                {
                    if (!(a == "X"))
                    {
                        if (!(a == "Y"))
                        {
                            if (!(a == "Z"))
                            {
                                if (!(a == "U"))
                                {
                                    if (!(a == "2P"))
                                    {
                                        goto IL_1E6;
                                    }
                                    normalVector = CommandLineQuerries.Specify2PDirection().BasisVector[2].Normalize();
                                }
                                else
                                {
                                    normalVector = Conversions.GetUCS().BasisVector[2].Normalize();
                                }
                            }
                            else
                            {
                                normalVector = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0);
                            }
                        }
                        else
                        {
                            normalVector = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0);
                        }
                    }
                    else
                    {
                        normalVector = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0);
                    }
                    Point point = new Point(0.0, 0.0, 0.0);
                    ngeometry.VectorGeometry.Plane plane = new ngeometry.VectorGeometry.Plane(point, normalVector);
                    CoordinateSystem coordinateSystem_   = new CoordinateSystem(plane);
                    PointProjection.string_3 = CommandLineQuerries.InsertOnLayer_Current_Face_Point(PointProjection.string_3);
                    PointProjection.string_2 = CommandLineQuerries.KeywordYesNo("Delete original points", PointProjection.string_2, false, false);
                    PointProjection.string_5 = CommandLineQuerries.KeepIfMultiple(PointProjection.string_5);
                    this.method_0(array, objectId_, coordinateSystem_);
                    return;
                }
IL_1E6:
                throw new System.Exception("Invalid option keyword.");
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message + "\n");
            }
        }
示例#7
0
        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);
            }
        }
示例#8
0
        public void ColorizeFacesCommand()
        {
            Editor        editor          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            ProgressMeter progressMeter   = new ProgressMeter();
            MessageFilter messageFilter   = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(messageFilter);
            try
            {
                ObjectId[] faceIDs = CommandLineQuerries.SelectFaces(false);
                CMD_Colorize.string_0 = CommandLineQuerries.SpecifyTargetProperty(CMD_Colorize.string_0);
                CMD_Colorize.string_1 = CommandLineQuerries.KeywordYesNo("Reverse color order", CMD_Colorize.string_1, false, false);
                CMD_Colorize.int_0    = CommandLineQuerries.SpecifyInteger("Specify number of colors", CMD_Colorize.int_0, 2, 32768, false, false);
                CMD_Colorize.double_0 = CommandLineQuerries.SpecifyDouble("Specify lower cutoff percentage", CMD_Colorize.double_0, false, true, false, true);
                CMD_Colorize.double_1 = CommandLineQuerries.SpecifyDouble("Specify upper cutoff percentage", CMD_Colorize.double_1, false, false, false, false);
                Global.SuspendEpsilon(0.0, 0.0);
                List <Triangle> list = Conversions.ToCeometricAcDbTriangleList(faceIDs);
                Global.ResumeEpsilon();
                double num              = 1.7976931348623157E+308;
                double num2             = -1.7976931348623157E+308;
                string formatFromLUPREC = DBManager.GetFormatFromLUPREC();
                string a;
                if ((a = CMD_Colorize.string_0) != null)
                {
                    if (!(a == "AN"))
                    {
                        if (!(a == "AR"))
                        {
                            if (!(a == "CZ"))
                            {
                                if (!(a == "MINZ"))
                                {
                                    if (!(a == "MAXZ"))
                                    {
                                        goto IL_714;
                                    }
                                    Triangle.Sort(list, Triangle.SortOrder.MaxZ);
                                    num  = list[0].MaximumZ;
                                    num2 = list[list.Count - 1].MaximumZ;
                                    editor.WriteMessage("\nMinimum maximum Z: " + num.ToString(formatFromLUPREC));
                                    editor.WriteMessage("\nMaximum maximum Z: " + num2.ToString(formatFromLUPREC));
                                }
                                else
                                {
                                    Triangle.Sort(list, Triangle.SortOrder.MinZ);
                                    num  = list[0].MinimumZ;
                                    num2 = list[list.Count - 1].MinimumZ;
                                    editor.WriteMessage("\nMinimum minimum Z: " + num.ToString(formatFromLUPREC));
                                    editor.WriteMessage("\nMaximum minimum Z: " + num2.ToString(formatFromLUPREC));
                                }
                            }
                            else
                            {
                                Triangle.Sort(list, Triangle.SortOrder.CenterZ);
                                num  = list[0].Center.Z;
                                num2 = list[list.Count - 1].Center.Z;
                                editor.WriteMessage("\nMinimum center Z: " + num.ToString(formatFromLUPREC));
                                editor.WriteMessage("\nMaximum center Z: " + num2.ToString(formatFromLUPREC));
                            }
                        }
                        else
                        {
                            Triangle.Sort(list, Triangle.SortOrder.Area);
                            num  = list[0].Area;
                            num2 = list[list.Count - 1].Area;
                            editor.WriteMessage("\nMinimum area: " + num.ToString(formatFromLUPREC));
                            editor.WriteMessage("\nMaximum area: " + num2.ToString(formatFromLUPREC));
                        }
                    }
                    else
                    {
                        Triangle.Sort(list, Triangle.SortOrder.MinimumAngle);
                        num  = list[0].MinimumAngle;
                        num2 = list[list.Count - 1].MinimumAngle;
                        editor.WriteMessage("\nMinimum minimum angle: " + (num * 180.0 / 3.1415926535897931).ToString(formatFromLUPREC) + " deg.");
                        editor.WriteMessage("\nMaximum minimum angle: " + (num2 * 180.0 / 3.1415926535897931).ToString(formatFromLUPREC) + " deg.");
                    }
                    progressMeter.SetLimit(list.Count);
                    progressMeter.Start("Colorizing property");
                    using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                    {
                        BlockTable       blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                        BlockTableRecord arg_3D7_0  = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                        int i = 0;
                        while (i < list.Count)
                        {
                            try
                            {
                                progressMeter.MeterProgress();
                                messageFilter.CheckMessageFilter((long)i, 1000);
                            }
                            catch (System.Exception ex)
                            {
                                progressMeter.Stop();
                                throw;
                            }
                            string a2;
                            if ((a2 = CMD_Colorize.string_0) != null)
                            {
                                double num3;
                                if (!(a2 == "AN"))
                                {
                                    if (!(a2 == "AR"))
                                    {
                                        if (!(a2 == "CZ"))
                                        {
                                            if (!(a2 == "MINZ"))
                                            {
                                                if (!(a2 == "MAXZ"))
                                                {
                                                    goto IL_6F4;
                                                }
                                                num3 = list[i].MaximumZ;
                                            }
                                            else
                                            {
                                                num3 = list[i].MinimumZ;
                                            }
                                        }
                                        else
                                        {
                                            num3 = list[i].Center.Z;
                                        }
                                    }
                                    else
                                    {
                                        num3 = list[i].Area;
                                    }
                                }
                                else
                                {
                                    num3 = list[i].MinimumAngle;
                                }
                                int    num4 = CMD_Colorize.int_0 - 1;
                                double num5 = Math.Abs((num3 - num) / (num2 - num));
                                if (100.0 * num5 <= CMD_Colorize.double_0)
                                {
                                    num5 = 0.0;
                                }
                                else if (100.0 * num5 >= CMD_Colorize.double_1)
                                {
                                    num5 = 1.0;
                                }
                                else
                                {
                                    num5 = num5 * 100.0 / (CMD_Colorize.double_1 - CMD_Colorize.double_0) - CMD_Colorize.double_0 / (CMD_Colorize.double_1 - CMD_Colorize.double_0);
                                }
                                num5 = Math.Round((double)num4 * num5, 0) / (double)num4;
                                if (CMD_Colorize.string_1 == "Y")
                                {
                                    num5 = 1.0 - num5;
                                }
                                double num6 = 0.2;
                                byte   b    = 0;
                                byte   b2   = 0;
                                byte   b3   = 0;
                                if (num5 < 0.2)
                                {
                                    b3 = (byte)(255.0 * (num5 - 0.0 * num6) / num6);
                                    b2 = 255;
                                }
                                else if (num5 < 2.0 * num6)
                                {
                                    b3 = 255;
                                    b2 = (byte)(255.0 - 255.0 * (num5 - 1.0 * num6) / num6);
                                }
                                else if (num5 < 3.0 * num6)
                                {
                                    b  = (byte)(255.0 * (num5 - 2.0 * num6) / num6);
                                    b3 = 255;
                                }
                                else if (num5 < 4.0 * num6)
                                {
                                    b  = 255;
                                    b3 = (byte)(255.0 - 255.0 * (num5 - 3.0 * num6) / num6);
                                }
                                else
                                {
                                    b  = 255;
                                    b2 = (byte)(255.0 * (num5 - 4.0 * num6) / num6);
                                }
                                Face face = (Face)transaction.GetObject(list[i].AcDbFace.ObjectId, (OpenMode)1);
                                face.Color = (Color.FromRgb(b, b3, b2));
                                i++;
                                continue;
                            }
IL_6F4:
                            throw new System.Exception("Invalid target property");
                        }
                        transaction.Commit();
                        goto IL_71F;
                    }
                    goto IL_714;
IL_71F:
                    progressMeter.Stop();
                    return;
                }
IL_714:
                throw new System.Exception("Invalid target property");
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                editor.WriteMessage("\n" + ex.Message);
            }
        }
示例#9
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");
            }
        }
示例#10
0
        public void ProjectLinesCommand()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[] objectId_  = CommandLineQuerries.SelectFaces(false);
                ObjectId[] objectId_2 = CommandLineQuerries.SelectLines(false);
                LineProjection.string_2 = CommandLineQuerries.SpecifyProjectionDirection(LineProjection.string_2);
                //new Vector3d(0.0, 0.0, 1.0);
                ngeometry.VectorGeometry.Vector3d directionVector  = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0);
                ngeometry.VectorGeometry.Vector3d directionVector2 = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0);
                string a;
                if ((a = LineProjection.string_2.ToUpper()) != null)
                {
                    if (!(a == "X"))
                    {
                        if (!(a == "Y"))
                        {
                            if (!(a == "Z"))
                            {
                                if (!(a == "U"))
                                {
                                    if (!(a == "2P"))
                                    {
                                        goto IL_267;
                                    }
                                    CommandLineQuerries.Specify2PDirection().BasisVector[2].Normalize();
                                }
                                else
                                {
                                    Conversions.GetUCS().BasisVector[2].Normalize();
                                }
                            }
                            else
                            {
                                directionVector  = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0);
                                directionVector2 = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0);
                                //new Vector3d(0.0, 0.0, 1.0);
                            }
                        }
                        else
                        {
                            directionVector  = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0);
                            directionVector2 = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0);
                            //new Vector3d(0.0, 1.0, 0.0);
                        }
                    }
                    else
                    {
                        directionVector  = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0);
                        directionVector2 = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0);
                        //new Vector3d(0.0, 0.0, 1.0);
                    }
                    ngeometry.VectorGeometry.Point point = new ngeometry.VectorGeometry.Point(0.0, 0.0, 0.0);
                    ngeometry.VectorGeometry.Plane plane = new ngeometry.VectorGeometry.Plane(point, directionVector, directionVector2);
                    CoordinateSystem coordinateSystem_   = new CoordinateSystem(plane);
                    LineProjection.string_1 = CommandLineQuerries.InsertOnLayer_Current_Face_Line(LineProjection.string_1);
                    LineProjection.string_0 = CommandLineQuerries.KeywordYesNo("Delete original lines", LineProjection.string_0, false, false);
                    this.method_0(objectId_2, objectId_, coordinateSystem_, true);
                    return;
                }
IL_267:
                throw new System.Exception("Invalid option keyword.");
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message + "\n");
            }
        }