コード例 #1
0
        public static PointSet SubdivideLine(Autodesk.AutoCAD.DatabaseServices.Line dbl, double d)
        {
            PointSet result;

            try
            {
                PointSet pointSet = new PointSet();
                ngeometry.VectorGeometry.Point point  = new ngeometry.VectorGeometry.Point(dbl.StartPoint.X, dbl.StartPoint.Y, dbl.StartPoint.Z);
                ngeometry.VectorGeometry.Point point2 = new ngeometry.VectorGeometry.Point(dbl.EndPoint.X, dbl.EndPoint.Y, dbl.EndPoint.Z);
                double num  = point.DistanceTo(point2);
                int    num2 = Math.Max((int)Math.Ceiling(num / d), 1);
                ngeometry.VectorGeometry.Vector3d vector = point2.method_2() - point.method_2();
                for (int i = 0; i <= num2; i++)
                {
                    double scalar = (double)i / (double)num2;
                    pointSet.Add(new Point(point.method_2() + scalar * vector));
                }
                result = pointSet;
            }
            catch (System.Exception ex)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Can not subdivide line (handle: " + dbl.Handle.ToString() + ")\n");
                result = null;
            }
            return(result);
        }
コード例 #2
0
        public static List <Edge> ToCeometricAcDbEdgeList(ObjectId[] lineIDs)
        {
            Database    workingDatabase = HostApplicationServices.WorkingDatabase;
            List <Edge> list            = new List <Edge>();

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                string     arg_1D_0 = SymbolUtilityServices.BlockModelSpaceName;
                LayerTable arg_30_0 = (LayerTable)transaction.GetObject(workingDatabase.LayerTableId, (OpenMode)0);
                for (int i = 0; i < lineIDs.Length; i++)
                {
                    Autodesk.AutoCAD.DatabaseServices.Line line = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(lineIDs[i], (OpenMode)0, true);
                    LayerTableRecord arg_66_0   = (LayerTableRecord)transaction.GetObject(line.LayerId, (OpenMode)0);
                    Point3d          startPoint = line.StartPoint;
                    Point3d          endPoint   = line.EndPoint;
                    ngeometry.VectorGeometry.Point startPoint2 = new ngeometry.VectorGeometry.Point(startPoint.X, startPoint.Y, startPoint.Z);
                    ngeometry.VectorGeometry.Point endPoint2   = new ngeometry.VectorGeometry.Point(endPoint.X, endPoint.Y, endPoint.Z);
                    list.Add(new Edge(startPoint2, endPoint2)
                    {
                        AcDbLine = line
                    });
                }
            }
            return(list);
        }
コード例 #3
0
        private void ConstructWorld(DocumentModifier docMdf, BlockTableRecord btr, string[] categories, double minMile,
                                    double maxMile)
        {
            var l = new Line(new Point3d(0, 0, 0), new Point3d(maxMile, 0, 0));

            btr.AppendEntity(l);
            docMdf.acTransaction.AddNewlyCreatedDBObject(l, true);
            //
            var txt = new DBText
            {
                TextString     = "左",
                Height         = Item.TextHeight,
                HorizontalMode = TextHorizontalMode.TextRight,
                VerticalMode   = TextVerticalMode.TextVerticalMid,
                AlignmentPoint = new Point3d(0, Item.BarHeight / 2, 0)
            };

            btr.AppendEntity(txt);
            docMdf.acTransaction.AddNewlyCreatedDBObject(txt, true);
            txt = new DBText
            {
                TextString     = "右",
                Height         = Item.TextHeight,
                HorizontalMode = TextHorizontalMode.TextRight,
                VerticalMode   = TextVerticalMode.TextVerticalMid,
                AlignmentPoint = new Point3d(0, -Item.BarHeight / 2, 0)
            };
            btr.AppendEntity(txt);
            docMdf.acTransaction.AddNewlyCreatedDBObject(txt, true);
            //
            foreach (var category in categories)
            {
                var middleVLeft  = Item.GetMiddleV(categories, category, true);
                var middleVRight = Item.GetMiddleV(categories, category, false);

                docMdf.WriteLineIntoDebuger(middleVRight.ToString(), middleVLeft.ToString());

                txt = new DBText
                {
                    TextString     = category,
                    Height         = Item.TextHeight,
                    HorizontalMode = TextHorizontalMode.TextRight,
                    VerticalMode   = TextVerticalMode.TextVerticalMid,
                    AlignmentPoint = new Point3d(0, middleVLeft, 0)
                };
                btr.AppendEntity(txt);
                docMdf.acTransaction.AddNewlyCreatedDBObject(txt, true);

                txt = new DBText
                {
                    TextString     = category,
                    Height         = Item.TextHeight,
                    HorizontalMode = TextHorizontalMode.TextRight,
                    VerticalMode   = TextVerticalMode.TextVerticalMid,
                    AlignmentPoint = new Point3d(0, middleVRight, 0)
                };
                btr.AppendEntity(txt);
                docMdf.acTransaction.AddNewlyCreatedDBObject(txt, true);
            }
        }
コード例 #4
0
        public static List <LineSegment3d> getLines(ObjectId[] ids)
        {
            List <LineSegment3d> ll = new List <LineSegment3d>();

            try
            {
                PLDictionary plDic = new PLDictionary();
                // Get the current document and database
                Document acDoc   = Application.DocumentManager.MdiActiveDocument;
                Database acCurDb = acDoc.Database;
                Editor   ed      = acDoc.Editor;
                // Start a transaction
                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    for (int i = 0; i < ids.Length; i++)
                    {
                        if (ids[i].ObjectClass != RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Line)))
                        {
                            continue;
                        }
                        Autodesk.AutoCAD.DatabaseServices.Line line = acTrans.GetObject(ids[i], OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Line;

                        ll.Add(new LineSegment3d(line.StartPoint, line.EndPoint));
                    }
                    ll = ll.Distinct(new My.CompareLineSegment3d()).ToList();// as

                    acTrans.Commit();
                }
            }
            catch (System.Exception ex)
            {
            }
            return(ll);
        }
コード例 #5
0
ファイル: Model.cs プロジェクト: gispda/InterCad
 /// <summary>
 /// Задание параметров отрезка класса Line.
 /// </summary>
 /// <param name="acadLine">Редактируемый отрезок</param>
 public void Update(ref AcadDS.Line acadLine)
 {
     if (acadLine != null)
     {
         acadLine.StartPoint = new Point3d(StartPoint.X, StartPoint.Y, Height);
         acadLine.EndPoint   = new Point3d(EndPoint.X, EndPoint.Y, Height);
     }
 }
コード例 #6
0
ファイル: Straight.cs プロジェクト: presscad/ExtensionAutoCAD
        protected override List <PathInfo> GetSweptPath()
        {
            AcadDB.Line line = new AcadDB.Line(start_position, end_position);

            List <PathInfo> ents = new List <PathInfo>();

            profile.BasePoint = StartPosition;
            ents.Add(new PathInfo(profile.GetRegions().First(), profile.GetSubRegions().First(), line, profile.BasePoint));

            return(ents);
        }
コード例 #7
0
ファイル: Model.cs プロジェクト: gispda/InterCad
 public Line(AcadDS.Line line)
 {
     _id         = line.Id;
     _name       = "line";
     _startPoint = new Coordinates()
     {
         X = line.StartPoint.X, Y = line.StartPoint.Y
     };
     _endPoint = new Coordinates()
     {
         X = line.EndPoint.X, Y = line.EndPoint.Y
     };
     _height = line.StartPoint.Z;
 }
コード例 #8
0
        public List <AcadDB.Entity> Draw()
        {
            List <AcadDB.Entity> ents = new List <AcadDB.Entity>();

            if (0 == steel_pos.Count)
            {
                return(ents);
            }

            AcadGeo.Point3d tmp_line = steel_pos[0];
            foreach (var sp in steel_pos)
            {
                AcadDB.Line line = new AcadDB.Line();
                line.StartPoint = sp + length_line * AcadGeo.Vector3d.XAxis + length_line * AcadGeo.Vector3d.YAxis;
                line.EndPoint   = sp - length_line * AcadGeo.Vector3d.XAxis - length_line * AcadGeo.Vector3d.YAxis;
                ents.Add(line);

                if (position.DistanceTo(sp) > position.DistanceTo(tmp_line))
                {
                    tmp_line = sp;
                }
            }
            ents.Add(new AcadDB.Line(position, tmp_line));

            ents.Add(new AcadDB.Circle(position - AcadGeo.Vector3d.XAxis * cir_radius, AcadGeo.Vector3d.ZAxis, cir_radius));

            //Draw number
            {
                AcadDB.DBText text = new AcadDB.DBText();
                text.TextString     = number.ToString();
                text.Justify        = AcadDB.AttachmentPoint.MiddleCenter;
                text.Height         = text_height;
                text.WidthFactor    = text_w_factor;
                text.AlignmentPoint = position - AcadGeo.Vector3d.XAxis * cir_radius;
                ents.Add(text);
            }

            //draw content
            {
                AcadDB.DBText text = new AcadDB.DBText();
                text.TextString     = content;
                text.Justify        = AcadDB.AttachmentPoint.BottomLeft;
                text.Height         = text_height;
                text.WidthFactor    = text_w_factor;
                text.AlignmentPoint = position + AcadGeo.Vector3d.XAxis * 10.0 + AcadGeo.Vector3d.YAxis * 10.0;
                ents.Add(text);
            }

            return(ents);
        }
コード例 #9
0
ファイル: IdEdge.cs プロジェクト: 1833183060/autocad-dev
        public IdEdge(Autodesk.AutoCAD.DatabaseServices.Line line)
        {
            //System.ComponentModel.LicenseManager.Validate(typeof(IdEdge));
            this.MinX = double.NaN;
            this.MaxX = double.NaN;
            this.MinY = double.NaN;
            this.MaxY = double.NaN;
            //base..ctor();
            this.Line = line;
            Point3d startPoint = line.StartPoint;
            Point3d endPoint   = line.EndPoint;

            this.Edge = new Edge(new Point(startPoint.X, startPoint.Y, startPoint.Z), new Point(endPoint.X, endPoint.Y, endPoint.Z));
            this.MinX = Math.Min(this.Edge.StartPoint.X, this.Edge.EndPoint.X);
            this.MaxX = Math.Max(this.Edge.StartPoint.X, this.Edge.EndPoint.X);
            this.MinY = Math.Min(this.Edge.StartPoint.Y, this.Edge.EndPoint.Y);
            this.MaxY = Math.Max(this.Edge.StartPoint.Y, this.Edge.EndPoint.Y);
        }
コード例 #10
0
        //ng:获得计算边界时所用的起点
        public static Point3d?getBoStartPoint(Point3d innerP, List <Autodesk.AutoCAD.DatabaseServices.Line> ll, PLDictionary plDic)
        {
            Autodesk.AutoCAD.DatabaseServices.Line resultL = new Autodesk.AutoCAD.DatabaseServices.Line();

            Point3d?resultP = null;

            if (ll == null)
            {
                return(null);
            }

            double intersectPointX = innerP.X;

            for (int i = 0; i < ll.Count; i++)
            {
                Point3d?p = getIntersectPoint2d(innerP.Y, ll[i]);
                if (p == null)
                {
                    continue;
                }
                if (resultP == null && p.Value.X > innerP.X)
                {
                    intersectPointX = p.Value.X;
                    resultL         = ll[i];
                }
                else
                {
                    if (p.Value.X > innerP.X && p.Value.X < intersectPointX)
                    {
                        intersectPointX = p.Value.X;
                        resultL         = ll[i];
                    }
                }
            }
            if (resultL.StartPoint.X < resultL.EndPoint.X)
            {
                resultP = resultL.StartPoint;
            }
            else
            {
                resultP = resultL.EndPoint;
            }
            return(resultP);
        }
コード例 #11
0
        /// <summary>
        /// Getting new ObjectId collection with objects which length are satisfy "needing_length"
        /// </summary>
        /// <param name="objects_id">List with ObjectId</param>
        /// <param name="needing_length">if 1 value -> search all line's that length is equal current;
        /// if 2 value -> search all line's that length is more first and less second; if 3 and more values -> search all line's that length is equal one of current list</param>
        /// <returns>List with ObjectId</returns>
        public static List <ObjectId> GetLinesByLength(Autodesk.AutoCAD.DynamoNodes.Document doc_dyn, List <ObjectId> objects_id, List <double> needing_length, int Accuracy = 8)
        {
            Document doc = doc_dyn.AcDocument;

            for (int i1 = 0; i1 < needing_length.Count; i1++)
            {
                double OneCheckeNum = needing_length[i1];
                needing_length[i1] = Math.Round(OneCheckeNum, Accuracy);
            }
            //Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            List <Autodesk.AutoCAD.DynamoNodes.Object> AcadObjects = new List <Autodesk.AutoCAD.DynamoNodes.Object>();
            List <ObjectId> selected_objects = new List <ObjectId>();

            using (DocumentLock acDocLock = doc.LockDocument())
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    foreach (ObjectId line_id in objects_id)
                    {
                        Autodesk.AutoCAD.DatabaseServices.Line OneObject = tr.GetObject(line_id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Line;
                        //if (LineType == 1) OneObject = OneObject as Polyline;
                        //else if (LineType == 2) OneObject = OneObject as Arc;
                        //else OneObject = OneObject as Line;
                        double LineLen = Math.Round(OneObject.Length, Accuracy);
                        //Autodesk.AutoCAD.DatabaseServices.Line OneObject = tr.GetObject(line_id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Line;
                        if (needing_length.Count == 1 && LineLen == needing_length[0])
                        {
                            selected_objects.Add(line_id);
                        }
                        else if (needing_length.Count == 2 && LineLen >= needing_length[0] && LineLen <= needing_length[1])
                        {
                            selected_objects.Add(line_id);
                        }
                        else if (needing_length.Contains(LineLen))
                        {
                            selected_objects.Add(line_id);
                        }
                    }
                    tr.Commit();
                }
            }
            return(selected_objects);
        }
コード例 #12
0
ファイル: Model.cs プロジェクト: presscad/ExtensionAutoCAD
        private static List <AcadGeo.Point3d> ParseLine(AcadDB.ObjectId id, List <AcadDB.ObjectId> ids)
        {
            List <AcadGeo.Point3d> pnts = new List <AcadGeo.Point3d>();

            using (AcadDB.Transaction tr = AcadFuncs.GetActiveDB().TransactionManager.StartTransaction())
            {
                AcadDB.Entity ent = tr.GetObject(id, AcadDB.OpenMode.ForRead) as AcadDB.Entity;
                if (!(ent is AcadDB.Line))
                {
                    return(pnts);
                }

                AcadDB.Line line = ent as AcadDB.Line;
                pnts.Add(line.StartPoint);
                pnts.Add(line.EndPoint);

                foreach (var tmp_id in ids)
                {
                    if (id == tmp_id)
                    {
                        continue;
                    }

                    AcadDB.Entity             tmp_ent          = tr.GetObject(tmp_id, AcadDB.OpenMode.ForRead) as AcadDB.Entity;
                    AcadGeo.Point3dCollection intersected_pnts = new AcadGeo.Point3dCollection();
                    line.IntersectWith(tmp_ent, AcadDB.Intersect.OnBothOperands, intersected_pnts, (IntPtr)0, (IntPtr)0);

                    for (int i = 0; i < intersected_pnts.Count; i++)
                    {
                        if (intersected_pnts[i].IsEqualTo(line.StartPoint) || intersected_pnts[i].IsEqualTo(line.EndPoint))
                        {
                            continue;
                        }

                        pnts.Add(intersected_pnts[i]);
                    }
                }
            }

            pnts.Sort((x, y) => x.DistanceTo(pnts.First()).CompareTo(y.DistanceTo(pnts.First())));
            pnts = pnts.Distinct().ToList();
            return(pnts);
        }
コード例 #13
0
ファイル: AcadUtil.cs プロジェクト: 1833183060/autocad-dev
        public static Extents3d?getBound(ObjectId[] idArray)
        {
            Database  workingDatabase = HostApplicationServices.WorkingDatabase;
            Extents3d?r = null;

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                for (int i = 0; i < idArray.Length; i++)
                {
                    DBObject @object = transaction.GetObject(idArray[i], (OpenMode)0);
                    if (!(@object == null))
                    {
                        Autodesk.AutoCAD.DatabaseServices.Line line = @object as Autodesk.AutoCAD.DatabaseServices.Line;
                        if (line != null)
                        {
                        }
                        else
                        {
                            Polyline polyline = @object as Polyline;
                            if (polyline != null)
                            {
                                r = polyline.Bounds;
                            }
                            Polyline2d polyline2d = @object as Polyline2d;
                            if (polyline2d != null)
                            {
                                r = polyline2d.Bounds;
                            }
                            Polyline3d polyline3d = @object as Polyline3d;
                            if (polyline3d != null)
                            {
                                if (r != null)
                                {
                                    r.Value.AddExtents(polyline3d.Bounds.Value);
                                }
                                r = polyline3d.Bounds;
                            }
                        }
                    }
                }
            }
            return(r);
        }
コード例 #14
0
        public static List <Edge> ToCeometricCADDataEdgeList(ObjectId[] lineIDs)
        {
            Database    workingDatabase = HostApplicationServices.WorkingDatabase;
            List <Edge> list            = new List <Edge>();

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                string     blockModelSpaceName = SymbolUtilityServices.BlockModelSpaceName;
                LayerTable arg_30_0            = (LayerTable)transaction.GetObject(workingDatabase.LayerTableId, (OpenMode)0);
                for (int i = 0; i < lineIDs.Length; i++)
                {
                    Autodesk.AutoCAD.DatabaseServices.Line line = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(lineIDs[i], (OpenMode)0, true);
                    LayerTableRecord layerTableRecord           = (LayerTableRecord)transaction.GetObject(line.LayerId, (OpenMode)0);
                    Autodesk.AutoCAD.Colors.Color color         = line.Color;
                    if (color.IsByLayer)
                    {
                        color = layerTableRecord.Color;
                    }
                    System.Drawing.Color empty = System.Drawing.Color.Empty;
                    short colorIndex           = 256;
                    Conversions.GetColors(color, ref empty, ref colorIndex);
                    CADData cADData = new CADData();
                    cADData.Layer.Name = layerTableRecord.Name;
                    cADData.Color      = empty;
                    cADData.ColorIndex = colorIndex;
                    cADData.BlockName  = blockModelSpaceName;
                    Point3d startPoint = line.StartPoint;
                    Point3d endPoint   = line.EndPoint;
                    ngeometry.VectorGeometry.Point startPoint2 = new ngeometry.VectorGeometry.Point(startPoint.X, startPoint.Y, startPoint.Z);
                    ngeometry.VectorGeometry.Point endPoint2   = new ngeometry.VectorGeometry.Point(endPoint.X, endPoint.Y, endPoint.Z);
                    list.Add(new Edge(startPoint2, endPoint2)
                    {
                        CADData = cADData
                    });
                }
            }
            return(list);
        }
コード例 #15
0
        public static Point3d?getIntersectPoint2d(double y, Autodesk.AutoCAD.DatabaseServices.Line line)
        {
            Point3d?r = null;

            if ((y > line.StartPoint.Y && y > line.EndPoint.Y) || (y < line.StartPoint.Y && y < line.EndPoint.Y))
            {
                return(null);
            }
            if (y == line.StartPoint.Y)
            {
                r = new Point3d(line.StartPoint.X, y, 0);
            }
            else if (y == line.EndPoint.Y)
            {
                r = new Point3d(line.EndPoint.X, y, 0);
            }
            else
            {
                double x = (y - line.StartPoint.Y) / (line.EndPoint.Y - line.StartPoint.Y) * (line.EndPoint.X - line.StartPoint.X) + line.StartPoint.X;
                r = new Point3d(x, y, 0);
            }

            return(r);
        }
コード例 #16
0
        public static List <Point3d> getOutterBo(ObjectId[] ids)
        {
            return(null);

            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            Editor   ed      = acDoc.Editor;

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;
                // Open the Block table record Model space for write
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;
                List <Autodesk.AutoCAD.DatabaseServices.Line> ll = new List <Autodesk.AutoCAD.DatabaseServices.Line>();
                DBObjectCollection acDBObjColl = new DBObjectCollection();
                for (int i = 0; i < ids.Length; i++)
                {
                    if (ids[i].ObjectClass != RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Line)))
                    {
                        continue;
                    }
                    Autodesk.AutoCAD.DatabaseServices.Line line = acTrans.GetObject(ids[i], OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Line;

                    ll.Add(line);
                }
                ll = ll.Distinct(new My.CompareLine()).ToList();// as

                acTrans.Commit();
            }
        }
コード例 #17
0
        public static Dictionary <string, object> GetLineIdBetweenLines(Autodesk.AutoCAD.DynamoNodes.Document doc_dyn, ds_g.Point pnt, List <ObjectId> all_objects, List <ObjectId> arrow_lines, double SearchRadius = 0.01)
        {
            //Document doc = Application.DocumentManager.MdiActiveDocument;
            Document doc      = doc_dyn.AcDocument;
            Database db       = doc.Database;
            Point3d  pnt_acad = new Point3d(pnt.X, pnt.Y, 0.0);

            List <ObjectId> lines_need_check = new List <ObjectId>();
            ObjectId        need_object      = ObjectId.Null;

            ds_g.Point EndPoint = null;
            foreach (ObjectId OneLine in all_objects)
            {
                if (!arrow_lines.Contains(OneLine))
                {
                    lines_need_check.Add(OneLine);
                }
            }
            if (arrow_lines.Count == 2 && all_objects.Count > 2)
            {
                using (DocumentLock acDocLock = doc.LockDocument())
                {
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        Autodesk.AutoCAD.DatabaseServices.Line arrow1 = tr.GetObject(arrow_lines[0], OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Line;
                        Autodesk.AutoCAD.DatabaseServices.Line arrow2 = tr.GetObject(arrow_lines[1], OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Line;
                        foreach (ObjectId line_id in lines_need_check)
                        {
                            Autodesk.AutoCAD.DatabaseServices.Line OneObject = tr.GetObject(line_id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Line;
                            Point3d line_sp = OneObject.StartPoint; Point3d line_ep = OneObject.EndPoint;
                            double  LineLen = OneObject.Length;

                            Point3d p1 = new Point3d(line_sp.X + SearchRadius / LineLen * (line_ep.X - line_sp.X), line_sp.Y + SearchRadius / LineLen * (line_ep.Y - line_sp.Y), 0.0);
                            Point3d p2 = new Point3d(line_ep.X + SearchRadius / LineLen * (line_sp.X - line_ep.X), line_ep.Y + SearchRadius / LineLen * (line_sp.Y - line_ep.Y), 0.0);
                            Point3d p_middle = new Point3d((line_sp.X + line_ep.X) / 2.0, (line_sp.Y + line_ep.Y) / 2.0, 0.0);
                            Point3d p_start;

                            if (GetLenByPoints(pnt_acad, p1) < SearchRadius * 2)
                            {
                                p_start  = p1;
                                EndPoint = ds_g.Point.ByCoordinates(line_ep.X, line_ep.Y, 0);
                            }
                            else
                            {
                                p_start  = p2;
                                EndPoint = ds_g.Point.ByCoordinates(line_sp.X, line_sp.Y, 0);
                            }

                            //if ( GetSideOfPointByLine(arrow1.StartPoint, arrow1.EndPoint, p_start) * GetSideOfPointByLine(arrow2.StartPoint, arrow2.EndPoint, p_start) <0 &&
                            //    GetSideOfPointByLine(arrow2.EndPoint, arrow1.EndPoint, p_start) * GetSideOfPointByLine(arrow2.EndPoint, arrow1.EndPoint, p_middle) < 0)
                            if (IsPointIntoTriangle(arrow1.EndPoint, arrow2.EndPoint, pnt_acad, p_start))
                            {
                                need_object = line_id;
                                break;
                            }
                            bool IsPointIntoTriangle(Point3d t1, Point3d t2, Point3d t3, Point3d c)
                            {
                                double ch1 = (t1.X - c.X) * (t2.Y - t1.Y) - (t2.X - t1.X) * (t1.Y - c.Y);
                                double ch2 = (t2.X - c.X) * (t3.Y - t2.Y) - (t3.X - t2.X) * (t2.Y - c.Y);
                                double ch3 = (t3.X - c.X) * (t1.Y - t3.Y) - (t1.X - t3.X) * (t3.Y - c.Y);

                                if ((ch1 >= 0 && ch2 >= 0 && ch3 >= 0) || (ch1 <= 0 && ch2 <= 0 && ch3 <= 0))
                                {
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                        tr.Commit();
                    }
                }
            }

            return(new Dictionary <string, object>
            {
                { "LineId", need_object }, { "LineEndPoint", EndPoint }
            });
        }
コード例 #18
0
        private List <Edge> method_0(ObjectId[] objectId_0, ObjectId[] objectId_1, CoordinateSystem coordinateSystem_0, bool bool_0)
        {
            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);
            int         num        = 0;
            int         num2       = 0;
            int         num3       = 0;
            IdEdgeList  idEdgeList = new IdEdgeList();
            List <Edge> list       = new List <Edge>();
            int         num4       = DBManager.SetEpsilon();
            int         num5       = (int)Convert.ToInt16(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("LUPREC").ToString());

            num4 = Math.Min(num5 + 2, num4);
            double num6 = Math.Max(Math.Pow(10.0, (double)(-(double)num4)), Global.AbsoluteEpsilon);
            CoordinateTransformator coordinateTransformator = new CoordinateTransformator(CoordinateSystem.Global(), coordinateSystem_0);
            CoordinateTransformator inverseTransformation   = coordinateTransformator.GetInverseTransformation();
            List <Triangle>         list2 = Conversions.ToCeometricAcDbTriangleList(objectId_1);

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                ObjectId         layerId          = DBManager.CurrentLayerId();
                DBManager.CurrentLayerName();
                List <IdEdge> list3 = new List <IdEdge>();
                double        num7  = -1.7976931348623157E+308;
                for (int i = 0; i < objectId_0.Length; i++)
                {
                    Autodesk.AutoCAD.DatabaseServices.Line line = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(objectId_0[i], (OpenMode)1, true);
                    IdEdge idEdge = new IdEdge(line);
                    if (LineProjection.string_0 == "Y" & !idEdge.Line.IsErased)
                    {
                        idEdge.Line.Erase();
                    }
                    coordinateTransformator.Transform(idEdge.Edge);
                    double num8  = idEdge.Edge.StartPoint.X - idEdge.Edge.EndPoint.X;
                    double num9  = idEdge.Edge.StartPoint.Y - idEdge.Edge.EndPoint.Y;
                    double num10 = Math.Sqrt(num8 * num8 + num9 * num9);
                    if (Math.Abs(num8) > num7)
                    {
                        num7 = Math.Abs(num8);
                    }
                    if (num10 < Global.AbsoluteEpsilon)
                    {
                        num2++;
                    }
                    else
                    {
                        idEdge.SetMinMaxXY();
                        list3.Add(idEdge);
                    }
                }
                list3.Sort(new CompareMin());
                progressMeter.SetLimit(objectId_1.Length);
                if ((double)objectId_1.Length > 10000.0)
                {
                    progressMeter.Start("Projecting lines...");
                }
                try
                {
                    for (int j = 0; j < list2.Count; j++)
                    {
                        progressMeter.MeterProgress();
                        messageFilter.CheckMessageFilter((long)j, 1000);
                        Triangle triangle = list2[j];
                        coordinateTransformator.Transform(triangle);
                        if (Math.Abs(triangle.NormalVector.Z) < Global.AbsoluteEpsilon)
                        {
                            num++;
                        }
                        else
                        {
                            double minimumX = triangle.MinimumX;
                            double maximumX = triangle.MaximumX;
                            double minimumY = triangle.MinimumY;
                            double maximumY = triangle.MaximumY;
                            IdEdge item     = new IdEdge(new Edge(new Point(maximumX, minimumY, 0.0), new Point(maximumX + 1.0, minimumY, 0.0)));
                            int    num11    = list3.BinarySearch(item, new CompareMin());
                            if (num11 < 0)
                            {
                                num11 = ~num11;
                            }
                            IdEdge item2 = new IdEdge(new Edge(new Point(minimumX - num7, maximumY, 0.0), new Point(minimumX - num7 + 1.0, maximumY, 0.0)));
                            int    num12 = list3.BinarySearch(item2, new CompareMin());
                            if (num12 < 0)
                            {
                                num12 = ~num12;
                            }
                            try
                            {
                                for (int k = num12; k < num11; k++)
                                {
                                    IdEdge idEdge2 = list3[k];
                                    if (idEdge2.MinX <= maximumX && idEdge2.MinY <= maximumY && idEdge2.MaxX >= minimumX && idEdge2.MaxY >= minimumY)
                                    {
                                        Edge   edge  = idEdge2.Edge;
                                        double num13 = Predicate.InTriangle2dArbitraryExact(triangle.Vertex1, triangle.Vertex2, triangle.Vertex3, edge.StartPoint);
                                        double num14 = Predicate.InTriangle2dArbitraryExact(triangle.Vertex1, triangle.Vertex2, triangle.Vertex3, edge.EndPoint);
                                        Edge   edge2 = new Edge();
                                        if (!double.IsNaN(num14) && !double.IsNaN(num13))
                                        {
                                            if (num14 == 1.0 && num13 == 1.0)
                                            {
                                                edge2 = edge;
                                            }
                                            else if (num13 == 1.0 && num14 == 0.0)
                                            {
                                                edge2 = edge;
                                            }
                                            else if (num13 == 0.0 && num14 == 1.0)
                                            {
                                                edge2 = edge;
                                            }
                                            else if (num13 == 0.0 && num14 == 0.0)
                                            {
                                                edge2 = edge;
                                            }
                                            else if (num13 == -1.0 && num14 == 1.0)
                                            {
                                                edge2 = this.method_1(edge, triangle, edge.EndPoint);
                                            }
                                            else if (num13 == 1.0 && num14 == -1.0)
                                            {
                                                edge2 = this.method_1(edge, triangle, edge.StartPoint);
                                            }
                                            else if (num13 == 0.0 && num14 == -1.0)
                                            {
                                                edge2 = this.method_2(edge, triangle, edge.StartPoint);
                                            }
                                            else if (num13 == -1.0 && num14 == 0.0)
                                            {
                                                edge2 = this.method_2(edge, triangle, edge.EndPoint);
                                            }
                                            else if (num13 == -1.0 && num14 == -1.0)
                                            {
                                                edge2 = this.method_3(edge, triangle);
                                            }
                                            if (!(edge2 == null))
                                            {
                                                Edge edge3 = edge2.DeepCopy();
                                                edge3.StartPoint.Z = PointProjection.smethod_0(triangle, edge3.StartPoint);
                                                edge3.EndPoint.Z   = PointProjection.smethod_0(triangle, edge3.EndPoint);
                                                if (edge3.Length >= num6)
                                                {
                                                    Edge edge4 = edge3.DeepCopy();
                                                    edge4.SwapSort();
                                                    edge4.StartPoint.X = (double)((float)edge4.StartPoint.X);
                                                    edge4.StartPoint.Y = (double)((float)edge4.StartPoint.Y);
                                                    edge4.StartPoint.Z = (double)((float)edge4.StartPoint.Z);
                                                    edge4.EndPoint.X   = (double)((float)edge4.EndPoint.X);
                                                    edge4.EndPoint.Y   = (double)((float)edge4.EndPoint.Y);
                                                    edge4.EndPoint.Z   = (double)((float)edge4.EndPoint.Z);
                                                    if (!idEdgeList.ContainsKey(edge4))
                                                    {
                                                        idEdgeList.Add(edge4, null);
                                                        inverseTransformation.Transform(edge3);
                                                        list.Add(edge3);
                                                        if (bool_0)
                                                        {
                                                            Point3d point3d = new Point3d(edge3.StartPoint.X, edge3.StartPoint.Y, edge3.StartPoint.Z);
                                                            //point3d..ctor(edge3.StartPoint.X, edge3.StartPoint.Y, edge3.StartPoint.Z);
                                                            Point3d point3d2 = new Point3d(edge3.EndPoint.X, edge3.EndPoint.Y, edge3.EndPoint.Z);
                                                            //point3d2..ctor(edge3.EndPoint.X, edge3.EndPoint.Y, edge3.EndPoint.Z);
                                                            Autodesk.AutoCAD.DatabaseServices.Line line2 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d, point3d2);
                                                            if (LineProjection.string_1 == "C")
                                                            {
                                                                LayerTableRecord layerTableRecord = (LayerTableRecord)transaction.GetObject(triangle.AcDbFace.LayerId, (OpenMode)0);
                                                                Color            color            = triangle.AcDbFace.Color;
                                                                if (color.IsByLayer)
                                                                {
                                                                    color = layerTableRecord.Color;
                                                                }
                                                                line2.SetPropertiesFrom(triangle.AcDbFace);
                                                                line2.LayerId = (layerId);
                                                                line2.Color   = (color);
                                                            }
                                                            else if (LineProjection.string_1 == "F")
                                                            {
                                                                line2.SetPropertiesFrom(triangle.AcDbFace);
                                                            }
                                                            else if (LineProjection.string_1 == "L")
                                                            {
                                                                line2.SetPropertiesFrom(idEdge2.Line);
                                                            }
                                                            blockTableRecord.AppendEntity(line2);
                                                            transaction.AddNewlyCreatedDBObject(line2, true);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                editor.WriteMessage("\n" + ex.Message);
                                num3++;
                            }
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    progressMeter.Stop();
                    throw;
                }
                transaction.Commit();
            }
            progressMeter.Stop();
            if (bool_0)
            {
                editor.WriteMessage("\nNumber of lines projected             : " + idEdgeList.Count);
                editor.WriteMessage("\nNumber of failed faces                : " + num3);
                editor.WriteMessage("\nFaces parallel to projection direction: " + num);
                editor.WriteMessage("\nLines parallel to projection direction: " + num2);
            }
            return(list);
        }
コード例 #19
0
        /// <summary>
        /// Загружает в документ новые параметры слоев и фигур.
        /// </summary>
        public void Update()
        {
            // Получаем текущий документ, доступ к командной строке и БД.
            Document doc = AcadAS.Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            Database db  = doc.Database;

            // Блокируем документ для редактирования из вне.
            using (DocumentLock lc = doc.LockDocument())
            {
                // Начинаем транзакцию.
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    try
                    {
                        // Создаем список имен слоев.
                        string[] layerNames = new string[Layers.Count];
                        int      i          = 0;
                        foreach (Layer layer in Layers)
                        {
                            layerNames[i] = layer.Name;
                            i++;
                        }

                        i = 0;
                        // Получаем таблицу слоев.
                        LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForWrite);
                        // Задаем временные имена слоев для избежания конфликтов переименовывания.
                        foreach (ObjectId ltrId in lt)
                        {
                            LayerTableRecord ltr = (LayerTableRecord)tr.GetObject(ltrId, OpenMode.ForWrite);
                            if (ltr.Name != "0")
                            {
                                ltr.Name = "_temp_" + ltr.Name + "_temp_";
                            }
                        }

                        foreach (Layer layer in Layers)
                        {
                            // Проверяем новое имя слоя на дублирование и присваиваем слоям документа новые параметры.
                            if (Array.IndexOf(layerNames, layer.Name) == Array.LastIndexOf(layerNames, layer.Name))
                            {
                                LayerTableRecord acadLayer = (LayerTableRecord)tr.GetObject(layer.Id, OpenMode.ForWrite);
                                layer.Update(ref acadLayer);
                            }
                            else if (Array.IndexOf(layerNames, layer.Name) == i)
                            {
                                MessageBox.Show("Дублирование имени слоя \"" + layer.Name + "\".");
                            }
                            i++;

                            // Присваиваем фигурам документа новые параметры.
                            foreach (Model.Point point in layer.Points)
                            {
                                AcadDS.DBPoint acadPoint = (AcadDS.DBPoint)tr.GetObject(point.Id, OpenMode.ForWrite);
                                point.Update(ref acadPoint);
                            }

                            foreach (Model.Line line in layer.Lines)
                            {
                                AcadDS.Line acadLine = (AcadDS.Line)tr.GetObject(line.Id, OpenMode.ForWrite);
                                line.Update(ref acadLine);
                            }

                            foreach (Model.Circle circle in layer.Circles)
                            {
                                AcadDS.Circle acadCircle = (AcadDS.Circle)tr.GetObject(circle.Id, OpenMode.ForWrite);
                                circle.Update(ref acadCircle);
                            }
                        }

                        // Если не все слои переименовались удаляем добавочный преффик и суффикс.
                        foreach (ObjectId ltrId in lt)
                        {
                            LayerTableRecord ltr = (LayerTableRecord)tr.GetObject(ltrId, OpenMode.ForWrite);
                            ltr.Name = ltr.Name.Replace("_temp_", "");
                        }
                    }
                    catch (Autodesk.AutoCAD.Runtime.Exception e)
                    {
                        ed.WriteMessage("error. {0}: {1}", e.Message);
                    }
                    tr.Commit();
                    tr.Dispose();
                }
                //lc.Dispose();
            }
            // Обновляем экземпляр класса после изменения документа.
            Reload();
        }
コード例 #20
0
ファイル: PreProcess.cs プロジェクト: 1833183060/autocad-dev
        //从直线集合中计算外围边界,直线在相交处都是打断的。得出的边界用点列表表示
        public static List <Point3d> getOuterBoundaryFromLine(ObjectId[] ids, Point3d?innerP)
        {
            List <Point3d> ret = null;

            try
            {
                PLDictionary plDic = new PLDictionary();
                // Get the current document and database
                Document acDoc   = Application.DocumentManager.MdiActiveDocument;
                Database acCurDb = acDoc.Database;
                Editor   ed      = acDoc.Editor;
                // Start a transaction
                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    // Open the Block table for read
                    BlockTable acBlkTbl;
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                                 OpenMode.ForRead) as BlockTable;
                    // Open the Block table record Model space for write
                    BlockTableRecord acBlkTblRec;
                    acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                    OpenMode.ForWrite) as BlockTableRecord;
                    List <Autodesk.AutoCAD.DatabaseServices.Line> ll = new List <Autodesk.AutoCAD.DatabaseServices.Line>();
                    DBObjectCollection acDBObjColl = new DBObjectCollection();
                    for (int i = 0; i < ids.Length; i++)
                    {
                        if (ids[i].ObjectClass != RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Line)))
                        {
                            continue;
                        }
                        Autodesk.AutoCAD.DatabaseServices.Line line = acTrans.GetObject(ids[i], OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Line;

                        ll.Add(line);
                    }
                    ll = ll.Distinct(new My.CompareLine()).ToList();// as List<Autodesk.AutoCAD.DatabaseServices.Line>;
                    plDic.Add(ll);
                    KeyValuePair <Point3d, Vector2d>?kvp = null;
                    if (innerP == null)
                    {
                        kvp = plDic.getLeftMost();//外部边界起始
                    }
                    else
                    {
                        //内部边界起始
                        kvp = Utility2d.getLeftMost(innerP.Value, ll, plDic);
                    }

                    if (kvp == null)
                    {
                        return(null);
                    }
                    Point3d        startP = kvp.Value.Key;
                    Point3d        curP   = kvp.Value.Key;
                    Vector2d       curV   = kvp.Value.Value;
                    List <Point3d> plist  = new List <Point3d>();
                    plist.Add(curP);
                    int maxLoopCount = plDic.Count;
                    while (maxLoopCount-- > 0)
                    {
                        Point3d?p = plDic.getMaxAnglePoint(curP, curV);
                        //ed.DrawVectors()
                        if (p == null)
                        {
                            break;
                        }
                        if (p.Value == startP)
                        {
                            break;
                        }
                        curV = new Vector2d(curP.X - p.Value.X, curP.Y - p.Value.Y);
                        curP = p.Value;

                        plist.Add(p.Value);
                    }
                    ret = plist;

                    acTrans.Commit();
                }
            }
            catch (System.Exception ex)
            {
            }
            return(ret);
        }
コード例 #21
0
        private void method_0(ObjectId[] objectId_0, ngeometry.VectorGeometry.Plane plane_0, int int_0)
        {
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            Editor        arg_15_0        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ProgressMeter progressMeter   = new ProgressMeter();
            MessageFilter messageFilter   = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(messageFilter);
            progressMeter.SetLimit(objectId_0.Length);
            progressMeter.Start("Slicing");
            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                try
                {
                    BlockTable arg_5A_0 = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)0);
                    for (int i = 0; i < objectId_0.Length; i++)
                    {
                        progressMeter.MeterProgress();
                        messageFilter.CheckMessageFilter((long)i, 1000);
                        Autodesk.AutoCAD.DatabaseServices.Line line = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                        Edge   edge   = Conversions.ToCeometricEdge(line);
                        double value  = edge.StartPoint.DistanceTo(plane_0);
                        double value2 = edge.EndPoint.DistanceTo(plane_0);
                        if (Math.Abs(value) < Global.AbsoluteEpsilon)
                        {
                            value = 0.0;
                        }
                        if (Math.Abs(value2) < Global.AbsoluteEpsilon)
                        {
                            value2 = 0.0;
                        }
                        int num  = Math.Sign(value);
                        int num2 = Math.Sign(value2);
                        if (num == num2)
                        {
                            if (num != int_0 && int_0 != 0)
                            {
                                line.UpgradeOpen();
                                if (!line.IsErased)
                                {
                                    line.Erase();
                                }
                            }
                        }
                        else
                        {
                            Point point = plane_0.method_0(edge.ToLine());
                            if (!(point == null))
                            {
                                line.UpgradeOpen();
                                BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(line.BlockId, (OpenMode)1);
                                Point3d          point3d          = new Point3d(edge.StartPoint.X, edge.StartPoint.Y, edge.StartPoint.Z);
                                Point3d          point3d2         = new Point3d(point.X, point.Y, point.Z);
                                Point3d          point3d3         = new Point3d(edge.EndPoint.X, edge.EndPoint.Y, edge.EndPoint.Z);
                                if (int_0 == 0)
                                {
                                    if (point3d != point3d2)
                                    {
                                        Autodesk.AutoCAD.DatabaseServices.Line line2 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d, point3d2);
                                        line2.SetPropertiesFrom(line);
                                        blockTableRecord.AppendEntity(line2);
                                        transaction.AddNewlyCreatedDBObject(line2, true);
                                    }
                                    if (point3d2 != point3d3)
                                    {
                                        Autodesk.AutoCAD.DatabaseServices.Line line3 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d2, point3d3);
                                        line3.SetPropertiesFrom(line);
                                        blockTableRecord.AppendEntity(line3);
                                        transaction.AddNewlyCreatedDBObject(line3, true);
                                    }
                                }
                                else if (Math.Sign(num) == int_0)
                                {
                                    Autodesk.AutoCAD.DatabaseServices.Line line4 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d, point3d2);
                                    line4.SetPropertiesFrom(line);
                                    blockTableRecord.AppendEntity(line4);
                                    transaction.AddNewlyCreatedDBObject(line4, true);
                                }
                                else if (Math.Sign(num2) == int_0)
                                {
                                    Autodesk.AutoCAD.DatabaseServices.Line line5 = new Autodesk.AutoCAD.DatabaseServices.Line(point3d2, point3d3);
                                    line5.SetPropertiesFrom(line);
                                    blockTableRecord.AppendEntity(line5);
                                    transaction.AddNewlyCreatedDBObject(line5, true);
                                }
                                if (!line.IsErased)
                                {
                                    line.Erase();
                                }
                            }
                        }
                    }
                    transaction.Commit();
                    progressMeter.Stop();
                }
                catch (System.Exception ex)
                {
                    progressMeter.Stop();
                    throw ex;
                }
            }
        }
コード例 #22
0
        private static Entity DrawPart(Segment[] segs, Point[] points, Point[] densifiedPoints, bool closePart, bool hasZ, double defaultElevation)
        {
            double num = 0.0;

            if (segs != null)
            {
                if (segs.Length == 1)
                {
                    CircularArc        circularArc = segs[0] as CircularArc;
                    EllipticArc        ellipticArc = segs[0] as EllipticArc;
                    BezierCurve        bezierCurve = segs[0] as BezierCurve;
                    ArcGIS10Types.Line line        = segs[0] as ArcGIS10Types.Line;
                    if (circularArc != null)
                    {
                        if (((PointN)circularArc.FromPoint).X == ((PointN)circularArc.ToPoint).X && ((PointN)circularArc.FromPoint).Y == ((PointN)circularArc.ToPoint).Y)
                        {
                            return(GIS2CAD.DrawCircle(circularArc, defaultElevation));
                        }
                        return(GIS2CAD.DrawCircularArc(circularArc, defaultElevation, densifiedPoints));
                    }
                    else if (ellipticArc != null)
                    {
                        if (!ellipticArc.IsCounterClockwise)
                        {
                            return(AGSEllipticalArc.ToCadSpline(ellipticArc, defaultElevation));
                        }
                        return(AGSEllipticalArc.ToCadEllipse(ellipticArc, defaultElevation));
                    }
                    else
                    {
                        if (line != null)
                        {
                            return(GIS2CAD.DrawPolyline(densifiedPoints, false));
                        }
                        if (bezierCurve != null)
                        {
                            return(GIS2CAD.DrawPolyline(densifiedPoints, closePart));
                        }
                    }
                }
                else if (segs.Length > 1)
                {
                    PointN pointN = segs[0].FromPoint as PointN;
                    num = pointN.Z;
                    if (num == 0.0)
                    {
                        num = defaultElevation;
                    }
                    if (GIS2CAD.CanBeDrawnAsPolyline(segs))
                    {
                        var polyline = new Autodesk.AutoCAD.DatabaseServices.Polyline();
                        polyline.ColorIndex = (256);
                        int    num2    = 0;
                        PointN pointN2 = (PointN)segs[0].ToPoint;
                        for (int i = 0; i < segs.Length; i++)
                        {
                            Segment     segment      = segs[i];
                            CircularArc circularArc2 = segment as CircularArc;
                            var         line2        = segment as ArcGIS10Types.Line;
                            if (line2 != null)
                            {
                                PointN pointN3 = (PointN)line2.FromPoint;
                                polyline.AddVertexAt(num2++, new Point2d(pointN3.X, pointN3.Y), 0.0, -1.0, -1.0);
                                pointN2 = (PointN)line2.ToPoint;
                            }
                            else if (circularArc2 != null)
                            {
                                PointN pointN4 = (PointN)circularArc2.CenterPoint;
                                PointN pointN5 = (PointN)circularArc2.FromPoint;
                                PointN pointN6 = (PointN)circularArc2.ToPoint;
                                new Point2d(pointN5.X - pointN4.X, pointN5.Y - pointN4.Y);
                                new Point2d(pointN6.X - pointN4.X, pointN6.Y - pointN4.Y);
                                Point2d point2d     = new Point2d(pointN5.X, pointN5.Y);
                                Point2d centerPoint = new Point2d(pointN4.X, pointN4.Y);
                                Point2d point2d2    = new Point2d(pointN6.X, pointN6.Y);
                                double  num3        = Math.Abs(centerPoint.GetDistanceTo(point2d));
                                double  num4        = Math.Abs(point2d.GetDistanceTo(point2d2));
                                double  num5        = num3;
                                double  num6        = num3;
                                double  d           = (num5 * num5 + num6 * num6 - num4 * num4) / (2.0 * num5 * num6);
                                double  num7        = Math.Acos(d);
                                num7 = GIS2CAD.CalcThetaFromVectors(point2d, point2d2, centerPoint, circularArc2.IsCounterClockwise);
                                double num8 = Math.Tan(num7 / 4.0);
                                if (!circularArc2.IsCounterClockwise)
                                {
                                    num8 *= -1.0;
                                }
                                polyline.AddVertexAt(num2++, point2d, num8, -1.0, -1.0);
                                pointN2 = pointN6;
                            }
                        }
                        polyline.AddVertexAt(num2, new Point2d(pointN2.X, pointN2.Y), 0.0, -1.0, -1.0);
                        if (closePart)
                        {
                            polyline.Closed = (true);
                        }
                        return(polyline);
                    }
                    return(GIS2CAD.Draw3dPline(densifiedPoints, closePart));
                }
            }
            else if (points != null)
            {
                if (points.Length == 2)
                {
                    var line3 = new Autodesk.AutoCAD.DatabaseServices.Line();
                    line3.ColorIndex = (256);
                    GIS2CAD.AdjustZ(ref points, defaultElevation);
                    Point3d startPoint = GIS2CAD.ToCadPoint3d((PointN)points[0]);
                    Point3d endPoint   = GIS2CAD.ToCadPoint3d((PointN)points[1]);
                    line3.StartPoint = (startPoint);
                    line3.EndPoint   = (endPoint);
                    return(line3);
                }
                if (points.Length > 0)
                {
                    if (!GIS2CAD.IsPlanar(points))
                    {
                        try
                        {
                            Document document           = AfaDocData.ActiveDocData.Document;
                            var      database           = document.Database;
                            var      transactionManager = document.TransactionManager;
                            using (document.LockDocument())
                            {
                                using (Transaction transaction = transactionManager.StartTransaction())
                                {
                                    BlockTable       blockTable       = (BlockTable)transaction.GetObject(database.BlockTableId, 0);
                                    BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[(BlockTableRecord.ModelSpace)], (OpenMode)1);
                                    Polyline3d       polyline3d       = new Polyline3d();
                                    polyline3d.ColorIndex = (256);
                                    blockTableRecord.AppendEntity(polyline3d);
                                    transaction.AddNewlyCreatedDBObject(polyline3d, true);
                                    Point[] array = points;
                                    for (int j = 0; j < array.Length; j++)
                                    {
                                        PointN           srcPt            = (PointN)array[j];
                                        PolylineVertex3d polylineVertex3d = new PolylineVertex3d(GIS2CAD.ToCadPoint3d(srcPt));
                                        polyline3d.AppendVertex(polylineVertex3d);
                                        transaction.AddNewlyCreatedDBObject(polylineVertex3d, true);
                                    }
                                    if (closePart)
                                    {
                                        polyline3d.Closed = (true);
                                    }
                                    document.TransactionManager.QueueForGraphicsFlush();
                                    document.TransactionManager.FlushGraphics();
                                    document.Editor.UpdateScreen();
                                    transaction.Commit();
                                    return(polyline3d);
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            string arg_526_0 = ex.Message;
                        }
                    }
                    var polyline2 = new Autodesk.AutoCAD.DatabaseServices.Polyline();
                    polyline2.ColorIndex = (256);
                    polyline2.Elevation  = (num);
                    num = ((PointN)points[0]).Z;
                    if (num == 0.0)
                    {
                        num = defaultElevation;
                    }
                    int     num9   = 0;
                    Point[] array2 = points;
                    for (int k = 0; k < array2.Length; k++)
                    {
                        PointN pointN7 = (PointN)array2[k];
                        polyline2.AddVertexAt(num9++, new Point2d(pointN7.X, pointN7.Y), 0.0, -1.0, -1.0);
                    }
                    if (closePart)
                    {
                        polyline2.Closed = (true);
                    }
                    return(polyline2);
                }
            }
            return(null);
        }
コード例 #23
0
 public static Edge ToCeometricEdge(Autodesk.AutoCAD.DatabaseServices.Line line)
 {
     ngeometry.VectorGeometry.Point startPoint = new ngeometry.VectorGeometry.Point(line.StartPoint.X, line.StartPoint.Y, line.StartPoint.Z);
     ngeometry.VectorGeometry.Point endPoint   = new ngeometry.VectorGeometry.Point(line.EndPoint.X, line.EndPoint.Y, line.EndPoint.Z);
     return(new Edge(startPoint, endPoint));
 }
コード例 #24
0
        private void method_0(ObjectId[] objectId_0, ProgressMeter progressMeter_0, CoordinateSystem coordinateSystem_0)
        {
            Database       workingDatabase = HostApplicationServices.WorkingDatabase;
            Editor         editor          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            List <Solid3d> list            = new List <Solid3d>();
            double         epsilon         = Convert.ToDouble(CMD_FacesToSolid.string_2);
            bool           flag            = true;

            if (CMD_FacesToSolid.string_0 == "N")
            {
                flag = false;
            }
            DBManager.SetEpsilon();
            List <Triangle> list2 = Conversions.ToCeometricAcDbTriangleList(objectId_0);

            if (!Conversions.IsWCS(coordinateSystem_0))
            {
                Triangle.TransformCoordinates(list2, CoordinateSystem.Global(), coordinateSystem_0);
            }
            list2.Sort(new Triangle.CompareMinX());
            int    num  = 0;
            double num2 = -1.7976931348623157E+308;
            double num3 = -1.7976931348623157E+308;
            double num4 = 1.7976931348623157E+308;
            double num5 = 1.7976931348623157E+308;

            for (int i = list2.Count - 1; i >= 0; i--)
            {
                if (list2[i].NormalVector.IsOrthogonalTo(new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0)))
                {
                    list2.RemoveAt(i);
                    num++;
                }
                else
                {
                    double minimumX = list2[i].MinimumX;
                    if (minimumX < num4)
                    {
                        num4 = minimumX;
                    }
                    double maximumX = list2[i].MaximumX;
                    if (maximumX > num2)
                    {
                        num2 = maximumX;
                    }
                    double minimumY = list2[i].MinimumY;
                    if (minimumY < num5)
                    {
                        num5 = minimumY;
                    }
                    double maximumY = list2[i].MaximumY;
                    if (maximumY > num3)
                    {
                        num3 = maximumY;
                    }
                }
            }
            ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(0.5 * (num4 + num2), 0.5 * (num5 + num3), 0.0);
            double num6 = 0.5 * Math.Max(Math.Abs(num2 - num4), Math.Abs(num3 - num5));
            double num7 = Math.Ceiling(100000.0 / num6);

            for (int j = 0; j < list2.Count; j++)
            {
                list2[j] = list2[j].Move(-1.0 * vector3d);
            }
            SubDMeshHandler subDMeshHandler = new SubDMeshHandler(list2);

            subDMeshHandler.BuildDataStructure(false);
            int k = 2147483647;

            while (k > 0)
            {
                this.messageFilter_0.CheckMessageFilter();
                k    = subDMeshHandler.HealXY(epsilon);
                num += k;
            }
            editor.WriteMessage("\nDegenerate projections healed: " + num);
            Autodesk.AutoCAD.Geometry.Matrix3d matrix3d  = Autodesk.AutoCAD.Geometry.Matrix3d.Scaling(num7, new Point3d(0.0, 0.0, 0.0));
            Autodesk.AutoCAD.Geometry.Matrix3d matrix3d2 = Autodesk.AutoCAD.Geometry.Matrix3d.Scaling(1.0 / num7, new Point3d(0.0, 0.0, 0.0));
            Autodesk.AutoCAD.Geometry.Matrix3d matrix3d3 = Autodesk.AutoCAD.Geometry.Matrix3d.Displacement(new Autodesk.AutoCAD.Geometry.Vector3d(vector3d.X, vector3d.Y, 0.0));
            progressMeter_0 = new ProgressMeter();
            progressMeter_0.SetLimit(objectId_0.Length);
            progressMeter_0.Start("Extruding objects");
            int num8 = 0;
            int num9 = 0;

            for (int l = 0; l < subDMeshHandler.FaceVertexIndex1.Count; l++)
            {
                try
                {
                    progressMeter_0.MeterProgress();
                    this.messageFilter_0.CheckMessageFilter((long)l, 1000);
                }
                catch (System.Exception ex)
                {
                    for (int m = 0; m < list.Count; m++)
                    {
                        list[m].Dispose();
                    }
                    progressMeter_0.Stop();
                    throw;
                }
                try
                {
                    Face   face = new Face(new Point3d(subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex1[l]].X, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex1[l]].Y, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex1[l]].Z), new Point3d(subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex2[l]].X, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex2[l]].Y, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex2[l]].Z), new Point3d(subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex3[l]].X, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex3[l]].Y, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex3[l]].Z), false, false, false, false);
                    double z    = face.GetVertexAt(0).Z;
                    double z2   = face.GetVertexAt(1).Z;
                    double z3   = face.GetVertexAt(2).Z;
                    short  num10;
                    if (CMD_FacesToSolid.double_0 < 0.0)
                    {
                        if (z <= z2 && z <= z3)
                        {
                            num10 = 0;
                        }
                        else if (z2 <= z && z2 <= z3)
                        {
                            num10 = 1;
                        }
                        else
                        {
                            num10 = 2;
                        }
                    }
                    else if (z >= z2 && z >= z3)
                    {
                        num10 = 0;
                    }
                    else if (z2 >= z && z2 >= z3)
                    {
                        num10 = 1;
                    }
                    else
                    {
                        num10 = 2;
                    }
                    Point3d vertexAt = face.GetVertexAt(num10);
                    Point3d point3d  = new Point3d(vertexAt.X, vertexAt.Y, vertexAt.Z + CMD_FacesToSolid.double_0);
                    //point3d..ctor(vertexAt.X, vertexAt.Y, vertexAt.Z + CMD_FacesToSolid.double_0);
                    Autodesk.AutoCAD.DatabaseServices.Line line = new Autodesk.AutoCAD.DatabaseServices.Line(vertexAt, point3d);
                    Region region = this.method_2(subDMeshHandler, l);
                    if (region == null)
                    {
                        num8++;
                    }
                    else
                    {
                        region.TransformBy(matrix3d);
                        line.TransformBy(matrix3d);
                        try
                        {
                            Solid3d solid3d = new Solid3d();
                            solid3d.ExtrudeAlongPath(region, line, 0.0);
                            solid3d.SetPropertiesFrom(face);
                            list.Add(solid3d);
                        }
                        catch (System.Exception ex)
                        {
                            num9++;
                        }
                        line.Dispose();
                        region.Dispose();
                    }
                }
                catch (System.Exception ex)
                {
                }
            }
            editor.WriteMessage("\nNumber of failed projections: " + num8.ToString());
            editor.WriteMessage("\nNumber of failed extrusions : " + num8.ToString());
            progressMeter_0.Stop();
            if (flag && list.Count > 1)
            {
                progressMeter_0 = new ProgressMeter();
                int limit = (int)Math.Ceiling(Math.Log((double)list.Count) / Math.Log(2.0));
                progressMeter_0.SetLimit(limit);
                progressMeter_0.Start("Building solid");
                this.method_1(ref list, ref progressMeter_0);
            }
            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                for (int n = 0; n < list.Count; n++)
                {
                    list[n].TransformBy(matrix3d2);
                    list[n].TransformBy(matrix3d3);
                    CoordinateTransformator coordinateTransformator = new CoordinateTransformator(coordinateSystem_0, CoordinateSystem.Global());
                    if (!coordinateTransformator.bool_0)
                    {
                        list[n].TransformBy(coordinateTransformator.ToAcadTransformation());
                    }
                    blockTableRecord.AppendEntity(list[n]);
                    transaction.AddNewlyCreatedDBObject(list[n], true);
                }
                transaction.Commit();
            }
            progressMeter_0.Stop();
        }
コード例 #25
0
        public static List <Edge> ToCeometricEdgeList(ObjectId[] idArray)
        {
            Database    workingDatabase = HostApplicationServices.WorkingDatabase;
            List <Edge> list            = new List <Edge>();

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                for (int i = 0; i < idArray.Length; i++)
                {
                    DBObject @object = transaction.GetObject(idArray[i], (OpenMode)0);
                    if (!(@object == null))
                    {
                        Autodesk.AutoCAD.DatabaseServices.Line line = @object as Autodesk.AutoCAD.DatabaseServices.Line;
                        if (line != null)
                        {
                            ngeometry.VectorGeometry.Point startPoint = Conversions.ToCeometricPoint(line.StartPoint);
                            ngeometry.VectorGeometry.Point endPoint   = Conversions.ToCeometricPoint(line.EndPoint);
                            list.Add(new Edge(startPoint, endPoint));
                        }
                        else
                        {
                            PointSet pointSet = null;
                            Polyline polyline = @object as Polyline;
                            if (polyline != null)
                            {
                                pointSet = PointGeneration.SubdivideLWPolyline(polyline, 0.0);
                                if (polyline.Closed)
                                {
                                    pointSet.Add(pointSet[0]);
                                }
                            }
                            Polyline2d polyline2d = @object as Polyline2d;
                            if (polyline2d != null)
                            {
                                pointSet = PointGeneration.SubdividePolyline2d(polyline2d, transaction, 0.0);
                                if (polyline2d.Closed)
                                {
                                    pointSet.Add(pointSet[0]);
                                }
                            }
                            Polyline3d polyline3d = @object as Polyline3d;
                            if (polyline3d != null)
                            {
                                pointSet = PointGeneration.SubdividePolyline3d(polyline3d, transaction, 0.0);
                                if (polyline3d.Closed)
                                {
                                    pointSet.Add(pointSet[0]);
                                }
                            }
                            if (pointSet != null)
                            {
                                for (int j = 0; j < pointSet.Count - 1; j++)
                                {
                                    list.Add(new Edge(pointSet[j], pointSet[j + 1]));
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
コード例 #26
0
ファイル: IO2.cs プロジェクト: 1833183060/autocad-dev
        private void method_1(ObjectId[] objectId_0)
        {
            Editor        editor          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            EntityList    entityList      = new EntityList();
            int           num             = 0;
            int           num2            = 0;
            int           num3            = 0;
            int           num4            = 0;
            MessageFilter messageFilter   = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(messageFilter);
            ProgressMeter progressMeter = new ProgressMeter();

            progressMeter.SetLimit(objectId_0.Length);
            progressMeter.Start("Serializing XML entities");
            try
            {
                CoordinateTransformator2 coordinateTransformator = new CoordinateTransformator2(CoordinateSystem.Global(), Conversions.GetUCS());
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    LayerTable arg_83_0 = (LayerTable)transaction.GetObject(workingDatabase.LayerTableId, (OpenMode)0);
                    for (int i = 0; i < objectId_0.Length; i++)
                    {
                        messageFilter.CheckMessageFilter((long)i, 10000);
                        progressMeter.MeterProgress();
                        Entity entity = (Entity)transaction.GetObject(objectId_0[i], (OpenMode)0);
                        string name   = ((LayerTableRecord)transaction.GetObject(entity.LayerId, (OpenMode)0)).Name;
                        Autodesk.AutoCAD.DatabaseServices.Face face = entity as Autodesk.AutoCAD.DatabaseServices.Face;
                        if (face != null)
                        {
                            Point3d vertexAt  = face.GetVertexAt(0);
                            Point3d vertexAt2 = face.GetVertexAt(1);
                            Point3d vertexAt3 = face.GetVertexAt(2);
                            Point3d vertexAt4 = face.GetVertexAt(3);
                            global::TerrainComputeC.XML.Vertex v     = new global::TerrainComputeC.XML.Vertex(vertexAt.X, vertexAt.Y, vertexAt.Z);
                            global::TerrainComputeC.XML.Vertex v2    = new global::TerrainComputeC.XML.Vertex(vertexAt2.X, vertexAt2.Y, vertexAt2.Z);
                            global::TerrainComputeC.XML.Vertex v3    = new global::TerrainComputeC.XML.Vertex(vertexAt3.X, vertexAt3.Y, vertexAt3.Z);
                            global::TerrainComputeC.XML.Vertex v4    = new global::TerrainComputeC.XML.Vertex(vertexAt4.X, vertexAt4.Y, vertexAt4.Z);
                            global::TerrainComputeC.XML.Face   face2 = new global::TerrainComputeC.XML.Face(v, v2, v3, v4);
                            face2.SetProperties(name, face.Color.ColorIndex);
                            entityList.Faces.Add(face2);
                            coordinateTransformator.Transform(face2);
                            num4++;
                        }
                        else
                        {
                            DBPoint dBPoint = entity as DBPoint;
                            if (dBPoint != null)
                            {
                                global::TerrainComputeC.XML.Point point = new global::TerrainComputeC.XML.Point(dBPoint.Position.X, dBPoint.Position.Y, dBPoint.Position.Z);
                                point.SetProperties(name, dBPoint.Color.ColorIndex);
                                entityList.Points.Add(point);
                                coordinateTransformator.Transform(point);
                                num++;
                            }
                            else
                            {
                                Autodesk.AutoCAD.DatabaseServices.Line line = entity as Autodesk.AutoCAD.DatabaseServices.Line;
                                if (line != null)
                                {
                                    Point3d startPoint = line.StartPoint;
                                    Point3d endPoint   = line.EndPoint;
                                    global::TerrainComputeC.XML.Vertex startVertex = new global::TerrainComputeC.XML.Vertex(startPoint.X, startPoint.Y, startPoint.Z);
                                    global::TerrainComputeC.XML.Vertex endVertex   = new global::TerrainComputeC.XML.Vertex(endPoint.X, endPoint.Y, endPoint.Z);
                                    global::TerrainComputeC.XML.Line   line2       = new global::TerrainComputeC.XML.Line(startVertex, endVertex);
                                    line2.SetProperties(name, line.Color.ColorIndex);
                                    entityList.Lines.Add(line2);
                                    coordinateTransformator.Transform(line2);
                                    num2++;
                                }
                                else
                                {
                                    Polyline   polyline   = entity as Polyline;
                                    Polyline2d polyline2d = entity as Polyline2d;
                                    Polyline3d polyline3d = entity as Polyline3d;
                                    if (polyline != null || polyline2d != null || polyline3d != null)
                                    {
                                        short colorIndex = 256;
                                        if (polyline != null)
                                        {
                                            colorIndex = polyline.Color.ColorIndex;
                                        }
                                        if (polyline2d != null)
                                        {
                                            colorIndex = polyline2d.Color.ColorIndex;
                                        }
                                        if (polyline3d != null)
                                        {
                                            colorIndex = polyline3d.Color.ColorIndex;
                                        }
                                        PointSet pointSet = PointGeneration.SubdividePolyline(entity, transaction, 0.0);
                                        List <global::TerrainComputeC.XML.Vertex> list = new List <global::TerrainComputeC.XML.Vertex>();
                                        for (int j = 0; j < pointSet.Count; j++)
                                        {
                                            list.Add(new global::TerrainComputeC.XML.Vertex(pointSet[j].X, pointSet[j].Y, pointSet[j].Z));
                                        }
                                        PolyLine polyLine = new PolyLine(list);
                                        polyLine.SetProperties(name, colorIndex);
                                        entityList.Polylines.Add(polyLine);
                                        coordinateTransformator.Transform(polyLine);
                                        num3++;
                                    }
                                }
                            }
                        }
                    }
                }
                progressMeter.Stop();
                editor.WriteMessage("\nXML entity list created:");
                editor.WriteMessage("\nNumber of points        : " + entityList.Points.Count);
                editor.WriteMessage("\nNumber of lines         : " + entityList.Lines.Count);
                editor.WriteMessage("\nNumber of polylines     : " + entityList.Polylines.Count);
                editor.WriteMessage("\nNumber of faces         : " + entityList.Faces.Count);
                editor.WriteMessage("\nTotal number of entities: " + entityList.Count);
                editor.WriteMessage("\nWriting xml file " + IO2.string_0 + "...");
                Serializer.Serialize(IO2.string_0, entityList);
                editor.WriteMessage("OK\n");
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                throw;
            }
        }
コード例 #27
0
        private PointSet method_1(ObjectId[] objectId_0, double double_1)
        {
            if (objectId_0 == null)
            {
                return(null);
            }
            Editor        arg_14_0        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            PointSet      pointSet        = new PointSet();
            PointSet      pointSet2       = new PointSet();
            ProgressMeter progressMeter   = new ProgressMeter();

            progressMeter.SetLimit(objectId_0.Length);
            progressMeter.Start("Computing points on entities");
            try
            {
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    for (int i = 0; i < objectId_0.Length; i++)
                    {
                        progressMeter.MeterProgress();
                        if (i % 10000 == 0)
                        {
                            System.Windows.Forms.Application.DoEvents();
                        }
                        Entity entity = (Entity)objectId_0[i].GetObject((OpenMode)0);
                        string text   = entity.ToString();
                        if (text.ToUpper().Contains("POLYLINE"))
                        {
                            text = "PLINE";
                        }
                        string key;
                        switch (key = text)
                        {
                        case "Autodesk.AutoCAD.DatabaseServices.Line":
                        {
                            Autodesk.AutoCAD.DatabaseServices.Line dbl = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = PointGeneration.SubdivideLine(dbl, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.DBText":
                        {
                            DBText dbtext_ = (DBText)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_2(dbtext_);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Circle":
                        {
                            Autodesk.AutoCAD.DatabaseServices.Circle circle_ = (Autodesk.AutoCAD.DatabaseServices.Circle)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_3(circle_, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Ellipse":
                        {
                            Autodesk.AutoCAD.DatabaseServices.Ellipse ellipse_ = (Autodesk.AutoCAD.DatabaseServices.Ellipse)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_4(ellipse_, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Arc":
                        {
                            Autodesk.AutoCAD.DatabaseServices.Arc arc_ = (Autodesk.AutoCAD.DatabaseServices.Arc)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_5(arc_, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Spline":
                        {
                            Spline spline_ = (Spline)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_6(spline_, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Face":
                        {
                            Face face_ = (Face)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_7(face_);
                            break;
                        }

                        case "PLINE":
                        {
                            DBObject @object = transaction.GetObject(objectId_0[i], (OpenMode)0);
                            pointSet2 = PointGeneration.SubdividePolyline(@object, transaction, double_1);
                            break;
                        }
                        }
                        if (pointSet2 != null)
                        {
                            pointSet.Add(pointSet2);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                throw;
            }
            progressMeter.Stop();
            if (pointSet.Count == 0)
            {
                return(null);
            }
            pointSet.RemoveMultiplePoints3d();
            return(pointSet);
        }