//假设现有实体entEntity ent = item as Entity;//如果实体为圆弧if (ent is Arc) {Arc arc = ent as Arc;double R = arc.Radius;Point3d startPoint = arc.StartPoint;Point3d endPoint = arc.EndPoint;Point2d p1, p2;p1 = new Point2d(startPoint.X, startPoint.Y);p2 = new Point2d(endPoint.X, endPoint.Y);Double L = p1.GetDistanceTo(p2);double H = R - Math.Sqrt(R * R - L * L / 4);Polyline poly = new Polyline();poly.AddVertexAt(0, p1, 2 * H / L, 0, 0);poly.AddVertexAt(1, p2, 0, 0, 0);poly.Color = reg.Color;poly.LineWeight = reg.LineWeight;poly.LinetypeId = reg.LinetypeId;btr.AppendEntity(poly);trans.AddNewlyCreatedDBObject(poly, true);}//如果实体为圆else if (ent is Circle) {Circle cir = ent as Circle;double r = cir.Radius;Point3d cc = cir.Center;Point2d p1 = new Point2d(cc.X + r, cc.Y);Point2d p2 = new Point2d(cc.X - r, cc.Y);Polyline poly = new Polyline();poly.AddVertexAt(0, p1, 1, 0, 0);poly.AddVertexAt(1, p2, 1, 0, 0);poly.AddVertexAt(2, p1, 1, 0, 0);poly.Color = reg.Color;poly.LineWeight = reg.LineWeight;poly.LinetypeId = reg.LinetypeId;btr.AppendEntity(poly);trans.AddNewlyCreatedDBObject(poly, true);}
600字范文,内容丰富有趣,生活中的好帮手!