예제 #1
0
        public void STLASCIIOutCommand()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                CommandLineQuerries.SpecifyFileNameForWrite(ref CMD_STL.string_2, ref CMD_STL.string_4, "stl");
                CMD_STL.string_1 = CommandLineQuerries.SpecifySTLType(CMD_STL.string_1);
                ObjectId[] array = CommandLineQuerries.SelectFaces(false);
                Global.SuspendEpsilon(0.0, 0.0);
                List <Triangle> list = Conversions.ToCeometricAcDbTriangleList(array);
                Global.ResumeEpsilon();
                string a;
                if ((a = CMD_STL.string_1) != null)
                {
                    if (!(a == "A"))
                    {
                        if (a == "B")
                        {
                            BinarySTL binarySTL = new BinarySTL();
                            binarySTL.Triangles = list;
                            for (int i = 0; i < list.Count; i++)
                            {
                                BinarySTL.STLColor sTLColor = new BinarySTL.STLColor();
                                sTLColor.R       = (byte)Math.Floor((double)list[i].AcDbFace.Color.Red / 8.0);
                                sTLColor.G       = (byte)Math.Floor((double)list[i].AcDbFace.Color.Green / 8.0);
                                sTLColor.B       = (byte)Math.Floor((double)list[i].AcDbFace.Color.Blue / 8.0);
                                sTLColor.IsValid = true;
                                sTLColor._cDef   = binarySTL.ColorDefinition;
                                binarySTL.Colors.Add(sTLColor);
                            }
                            binarySTL.Write(CMD_STL.string_2);
                            editor.WriteMessage("\nNumber of triangles written   : " + binarySTL.NumberOfTrianglesWritten.ToString());
                            editor.WriteMessage("\nNumber of degenerate triangles: " + binarySTL.NumberOfDegenerateTriangles.ToString());
                            editor.WriteMessage("\nHas negative coordinates      : " + binarySTL.HasNegativeCoordinates.ToString());
                            editor.WriteMessage("\nSTL file in binary format written to " + CMD_STL.string_2);
                        }
                    }
                    else
                    {
                        string   layerNameOfEntity = DBManager.GetLayerNameOfEntity(array[0]);
                        string   solidName         = CommandLineQuerries.SpecifyString("Specify STL solid name", layerNameOfEntity, true);
                        ASCIISTL aSCIISTL          = new ASCIISTL();
                        aSCIISTL.Triangles = list;
                        aSCIISTL.SolidName = solidName;
                        aSCIISTL.Write(CMD_STL.string_2);
                        editor.WriteMessage("\nNumber of triangles written   : " + aSCIISTL.NumberOfTrianglesWritten.ToString());
                        editor.WriteMessage("\nNumber of degenerate triangles: " + aSCIISTL.NumberOfDegenerateTriangles.ToString());
                        editor.WriteMessage("\nHas negative coordinates      : " + aSCIISTL.HasNegativeCoordinates.ToString());
                        editor.WriteMessage("\nSTL file in ASCII format written to " + CMD_STL.string_2);
                    }
                }
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
        }
예제 #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);
            }
        }
예제 #3
0
        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 ContourCommand()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                ObjectId[] objectId_ = CommandLineQuerries.SelectFaces(false);
                ContourLineComputation.string_0 = CommandLineQuerries.SpecifyReferencePlane(ContourLineComputation.string_0);
                CoordinateSystem coordinateSystem = CoordinateSystem.Global();
                if (ContourLineComputation.string_0 == "U")
                {
                    coordinateSystem = Conversions.GetUCS();
                }
                if (ContourLineComputation.string_0 == "3P")
                {
                    coordinateSystem = CommandLineQuerries.Specify3PSystem();
                }
                coordinateSystem.Orthonormalize();
                ContourLineComputation.startElevation = CommandLineQuerries.SpecifyDouble("Specify start elevation", ContourLineComputation.startElevation, false, true, false, true);
                ContourLineComputation.endElevation   = Math.Max(ContourLineComputation.endElevation, ContourLineComputation.startElevation);
                bool flag = false;
                while (!flag)
                {
                    ContourLineComputation.endElevation = CommandLineQuerries.SpecifyDouble("Specify end elevation", ContourLineComputation.endElevation, false, true, false, true);
                    if (ContourLineComputation.startElevation > ContourLineComputation.endElevation)
                    {
                        editor.WriteMessage("\nStart elevation must be less or equal end elevation.");
                    }
                    else
                    {
                        flag = true;
                    }
                }
                ContourLineComputation.spacing     = CommandLineQuerries.SpecifyDouble("Specify spacing", ContourLineComputation.spacing, false, false, false, false);
                ContourLineComputation.whatCADData = CommandLineQuerries.InsertOnLayer_Current_Face_Elevation_Index(ContourLineComputation.whatCADData);
                if (ContourLineComputation.whatCADData != "F" && ContourLineComputation.whatCADData != "C")
                {
                    ContourLineComputation.prefix = CommandLineQuerries.SpecifyPrefixString(ContourLineComputation.prefix);
                }
                this.genContour(objectId_, coordinateSystem);
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message + "\n");
            }
        }
예제 #5
0
        public void OUT3DF()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            ObjectId[] array = null;
            try
            {
                ////LicenseManager.CheckValid("FULL");
                IO2.string_6 = CommandLineQuerries.SpecifyEntitiesBySelectionOrByLayer(IO2.string_6);
                if (IO2.string_6 == "S")
                {
                    array = CommandLineQuerries.SelectFaces(true);
                }
                else if (IO2.string_6 == "L")
                {
                    IO2.string_7 = CommandLineQuerries.SpecifyLayerName(IO2.string_7);
                    if (!DBManager.ExistsLayer(IO2.string_7))
                    {
                        throw new ArgumentException("Layer does not exist.");
                    }
                    array = DBManager.GetFacesOnLayer(IO2.string_7);
                    if (array == null)
                    {
                        throw new ArgumentException("No faces selected.");
                    }
                    editor.WriteMessage(Environment.NewLine + array.Length + " faces selected.");
                }
                CommandLineQuerries.SpecifyFileNameForWrite(ref IO2.string_2, ref IO2.string_8, "3df");
                IO2.string_9 = CommandLineQuerries.SpecifyDelimiter(IO2.string_9);
                IO2.int_0    = CommandLineQuerries.SpecifyColumnWidth(IO2.int_0);
                IO2.int_1    = CommandLineQuerries.SpecifyDecimalDigits(IO2.int_1);
                this.method_3(array);
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine);
            }
        }
예제 #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 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);
            }
        }
예제 #8
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");
            }
        }
예제 #9
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");
            }
        }