Ejemplo n.º 1
0
        public static Polyline CircleToPoly(this QuickTransaction tr, Circle c)
        {
            var r = c.Radius;

            new Ellipse();
            var top       = c.Center.Add(new Vector3d(0, r, 0));
            var bottom    = c.Center.Add(new Vector3d(0, -r, 0));
            var right     = c.Center.Add(new Vector3d(r, 0, 0));
            var left      = c.Center.Add(new Vector3d(-r, 0, 0));
            var right_cir = new CircularArc3d(bottom, right, top);
            var left_cir  = new CircularArc3d(top, left, bottom);
            var poly      = new Polyline();

            poly.AddVertexAt(0, new Point2d(right_cir.StartPoint.X, right_cir.StartPoint.Y), right_cir.GetArcBulge(), 0, 0);
            poly.AddVertexAt(1, new Point2d(right_cir.EndPoint.X, right_cir.EndPoint.Y), 0, 0, 0);
            poly.AddVertexAt(2, new Point2d(left_cir.StartPoint.X, left_cir.StartPoint.Y), left_cir.GetArcBulge(), 0, 0);
            poly.AddVertexAt(3, new Point2d(left_cir.EndPoint.X, left_cir.EndPoint.Y), 0, 0, 0);
            poly.LayerId = c.LayerId;
            tr.BlockTableRecordCurrentSpace.AppendEntity(poly);
            tr.AddNewlyCreatedDBObject(poly, true);
            c.Erase();
            return(poly);
        }