600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > CAD C#二次开发 圆和圆弧转Polyline线

CAD C#二次开发 圆和圆弧转Polyline线

时间:2024-06-13 09:03:08

相关推荐

CAD C#二次开发  圆和圆弧转Polyline线

//假设现有实体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);}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。