- UID
- 769950
- 积分
- 64
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2017-7-25
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2017-8-3 14:19:44
|
显示全部楼层
//假设现有实体ent
Entity 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);
}
我网上找了下,是这个代码么
|
|