Esempio n. 1
0
        public static Polyline LineToPoly(this QuickTransaction tr, Line line)
        {
            if (tr == null)
            {
                throw new ArgumentNullException(nameof(tr));
            }
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }
            var btr = tr.BlockTableRecordCurrentSpace;

            line = tr.EnsureWritable(line);

            if (!line.IsWriteEnabled)
            {
                line = (Line)tr.GetObject(line.ObjectId, OpenMode.ForWrite);
            }
            var poly = new Polyline();

            poly.AddVertexAt(0, new Point2d(line.StartPoint.X, line.StartPoint.Y), 0, 0, 0);
            poly.AddVertexAt(1, new Point2d(line.EndPoint.X, line.EndPoint.Y), 0, 0, 0);
            poly.LayerId = line.LayerId;
            btr.AppendEntity(poly);
            tr.AddNewlyCreatedDBObject(poly, true);
            line.Erase();
            return(poly);
        }
Esempio n. 2
0
        public static Polyline ArcToPoly(this QuickTransaction tr, Arc arc)
        {
            var btr = tr.BlockTableRecordCurrentSpace;

            arc = tr.EnsureWritable(arc);
            var poly = new Polyline();

            poly.AddVertexAt(0, new Point2d(arc.StartPoint.X, arc.StartPoint.Y), arc.GetArcBulge(), 0, 0);
            poly.AddVertexAt(1, new Point2d(arc.EndPoint.X, arc.EndPoint.Y), 0, 0, 0);
            poly.LayerId = arc.LayerId;
            btr.AppendEntity(poly);
            tr.AddNewlyCreatedDBObject(poly, true);
            arc.Erase();
            return(poly);
        }