Ejemplo n.º 1
0
        public void moveText2interCmd()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            this.messageFilter_0 = new MessageFilter();
            System.Windows.Forms.Application.AddMessageFilter(this.messageFilter_0);
            try
            {
                PointSet   pointSet  = new PointSet();
                ObjectId[] objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.TEXT, "选择点:", false);
                if (objectIDs != null)
                {
                    Database workingDatabase = HostApplicationServices.WorkingDatabase;

                    using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                    {
                        for (int i = 0; i < objectIDs.Length; i++)
                        {
                            DBText text = (DBText)transaction.GetObject(objectIDs[i], OpenMode.ForWrite, true);

                            Point3d newP = moveText2inter(text.Position);
                            text.Position = newP;
                            editor.WriteMessage("" + newP.X + newP.Y);
                        }

                        transaction.Commit();
                    }


                    if (objectIDs.Length > 1)
                    {
                    }
                }
                else
                {
                    editor.WriteMessage("没有选择到点.\n");
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public void scale()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            this.messageFilter_0 = new MessageFilter();
            System.Windows.Forms.Application.AddMessageFilter(this.messageFilter_0);
            try
            {
                PointSet   pointSet  = new PointSet();
                ObjectId[] objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.POINT, "选择点:", false);
                if (objectIDs != null)
                {
                    Database workingDatabase = HostApplicationServices.WorkingDatabase;

                    using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                    {
                        for (int i = 0; i < objectIDs.Length; i++)
                        {
                            DBPoint dbPoint = (DBPoint)transaction.GetObject(objectIDs[i], OpenMode.ForWrite, true);

                            dbPoint.Position = new Autodesk.AutoCAD.Geometry.Point3d(dbPoint.Position.X, dbPoint.Position.Y, dbPoint.Position.Z * 5);
                        }
                        transaction.Commit();
                    }

                    string text = " triangulation point";
                    if (objectIDs.Length > 1)
                    {
                        text += "s";
                    }
                    editor.WriteMessage(objectIDs.Length + text + " selected.");
                }
                else
                {
                    editor.WriteMessage("没有选择到点.\n");
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Ejemplo n.º 4
0
        public void TesselateCommand()
        {
            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;
                PointSet pointSet = this.method_0(objectIDs, value);
                editor.WriteMessage("\n" + pointSet.Count + " points generated on solids.");
                DBManager.WriteListInDatabase <Point>(pointSet.ToList(), null, DBManager.EntityPropertiesAssignment.ByDialog, ObjectId.Null, ObjectId.Null);
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
        }
Ejemplo n.º 5
0
        public void tri2()
        {
            Editor   ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            PointSet ps = PreProcess.getPointFromText(mydb.tcSetting.Scale);

            ObjectId[] ids = PreProcess.getAllLines();

            List <Constraint> boundary = new List <Constraint>();

            //int plCount = 0;
            ObjectId[] objectIDs3 = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.PLINES, "Select boundaries (polylines)", false);
            if (objectIDs3 != null)
            {
                string text3 = " boundary";
                if (objectIDs3.Length > 1)
                {
                    text3 += "s";
                }
                //editor.WriteMessage(objectIDs3.Length + text3 + " selected.");
                //plCount = this.getPolylineCount(objectIDs3);
                List <Edge> list4 = Conversions.ToCeometricEdgeList(objectIDs3);
                for (int j = 0; j < list4.Count; j++)
                {
                    boundary.Add(new Constraint(list4[j], Constraint.ConstraintType.Boundary));
                }
            }
            else
            {
                //editor.WriteMessage("No boundaries selected.\n");
            }


            Triangulate tri = new Triangulate();

            //tri.TriangulateInternal(ps, new List<Constraint>(), new List<Constraint>());
            tri.TriangulateInternal(ps, new List <Constraint>(), boundary, null);
        }
Ejemplo n.º 6
0
        public void UserInterface()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            this.messageFilter = new MessageFilter();
            System.Windows.Forms.Application.AddMessageFilter(this.messageFilter);
            try
            {
                PointSet   pointSet  = new PointSet();
                ObjectId[] objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.POINT, "Select triangulation points", false);
                if (objectIDs != null)
                {
                    string text = " triangulation point";
                    if (objectIDs.Length > 1)
                    {
                        text += "s";
                    }
                    editor.WriteMessage(objectIDs.Length + text + " selected.");
                    pointSet.Add2(Conversions.ToCeometricPointSet2(objectIDs));
                }
                else
                {
                    editor.WriteMessage("No triangulation points selected.\n");
                }
                List <Constraint> list       = new List <Constraint>();
                ObjectId[]        objectIDs2 = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.LINE, "Select constraints (lines)", false);
                if (objectIDs2 != null)
                {
                    string text2 = " constraint";
                    if (objectIDs2.Length > 1)
                    {
                        text2 += "s";
                    }
                    editor.WriteMessage(objectIDs2.Length + text2 + " selected.");
                    List <Edge> list2 = Conversions.ToCeometricEdgeList(objectIDs2);
                    for (int i = 0; i < list2.Count; i++)
                    {
                        list.Add(new Constraint(list2[i], Constraint.ConstraintType.Constraint));
                    }
                }
                else
                {
                    editor.WriteMessage("No constraints selected.\n");
                }
                if (pointSet.Count == 0 && list.Count == 0)
                {
                    throw new ArgumentException("No triangulation points nor constraints.");
                }
                List <Constraint> bo  = new List <Constraint>();
                int        plCount    = 0;
                ObjectId[] objectIDs3 = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.PLINES, "Select boundaries (polylines)", false);
                if (objectIDs3 != null)
                {
                    string text3 = " boundary";
                    if (objectIDs3.Length > 1)
                    {
                        text3 += "s";
                    }
                    editor.WriteMessage(objectIDs3.Length + text3 + " selected.");
                    plCount = this.getPolylineCount(objectIDs3);
                    List <Edge> list4 = Conversions.ToCeometricEdgeList(objectIDs3);
                    for (int j = 0; j < list4.Count; j++)
                    {
                        bo.Add(new Constraint(list4[j], Constraint.ConstraintType.Boundary));
                    }
                }
                else
                {
                    editor.WriteMessage("No boundaries selected.\n");
                }
                if (list.Count > 0)
                {
                    Triangulate.int_0 = CommandLineQuerries.SpecifyInteger("Maximum feasible constraint violations", Triangulate.int_0, 0, 2147483647, false, true);
                }
                editor.WriteMessage("\nInitial triangulation:");
                editor.WriteMessage("\n----------------------");
                editor.WriteMessage("\nInitial triangulation points  : " + pointSet.Count);
                editor.WriteMessage("\nInitial constraints           : " + list.Count);
                editor.WriteMessage("\nNumber of boundary regions    : " + plCount);
                editor.WriteMessage("\nInitial boundary segments     : " + bo.Count);
                editor.WriteMessage("\n");
                this.TriangulateInternal(pointSet, list, bo, null);
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
            finally
            {
                try
                {
                    this.progressMeter_0.Stop();
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("feef");
                }
                try
                {
                    this.pane_0.Text    = ("");
                    this.pane_0.Visible = (false);
                    Autodesk.AutoCAD.ApplicationServices.Application.StatusBar.Update();
                    Autodesk.AutoCAD.ApplicationServices.Application.StatusBar.Panes.Remove(this.pane_0);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("efefe");
                }
                System.Windows.Forms.Application.DoEvents();
            }
        }
Ejemplo n.º 7
0
        internal PointSet method_0()
        {
            Editor   arg_0F_0 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database arg_15_0 = HostApplicationServices.WorkingDatabase;

            PointGeneration.string_0 = CommandLineQuerries.SpecifyEntityType(PointGeneration.string_0);
            string key;

            if ((key = PointGeneration.string_0) != null)
            {
                if (PrivateImplementationDetails40B.method0x60001441 == null)
                {
                    PrivateImplementationDetails40B.method0x60001441 = new Dictionary <string, int>(10)
                    {
                        {
                            "A",
                            0
                        },
                        {
                            "ALL",
                            1
                        },
                        {
                            "C",
                            2
                        },
                        {
                            "E",
                            3
                        },
                        {
                            "F",
                            4
                        },
                        {
                            "L",
                            5
                        },
                        {
                            "P",
                            6
                        },
                        {
                            "S",
                            7
                        },
                        {
                            "T",
                            8
                        },
                        {
                            "SO",
                            9
                        }
                    };
                }
                int num;
                if (PrivateImplementationDetails40B.method0x60001441.TryGetValue(key, out num))
                {
                    ObjectId[] objectIDs;
                    switch (num)
                    {
                    case 0:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.ARC);
                        break;

                    case 1:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.ArcLineTextCircleEllipseFaceSplinePline);
                        break;

                    case 2:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.CIRCLE);
                        break;

                    case 3:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.ELLIPSE);
                        break;

                    case 4:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.FACE);
                        break;

                    case 5:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.LINE);
                        break;

                    case 6:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.PLINES);
                        break;

                    case 7:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.SPLINE);
                        break;

                    case 8:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.TEXT);
                        break;

                    case 9:
                        objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.SOLID3D);
                        break;

                    default:
                        goto IL_1B1;
                    }
                    if (objectIDs == null)
                    {
                        return(null);
                    }
                    if (!(PointGeneration.string_0 == "T") && !(PointGeneration.string_0 == "F"))
                    {
                        PointGeneration.double_0 = CommandLineQuerries.SpecifyDouble("Enter maximum subdivision distance or 0 for no subdivision", PointGeneration.double_0, false, false, false, true);
                        return(this.method_1(objectIDs, PointGeneration.double_0));
                    }
                    return(this.method_1(objectIDs, 0.0));
                }
            }
IL_1B1:
            throw new ArgumentException("Invalid option keyword.");
        }