- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
public static void Jumper()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Matrix3d ucs = ed.CurrentUserCoordinateSystem;
Database db = doc.Database;
PromptEntityResult res = ed.GetEntity(new PromptEntityOptions("Select polyline : "));
if (res.Status != PromptStatus.OK) return;
ObjectId id = res.ObjectId;
Point3d pp = res.PickedPoint;
// Set break gap
double gap = 3.0;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
Entity ent = tr.GetObject(id, OpenMode.ForWrite) as Entity;
Polyline poly = ent as Polyline;
if (poly == null) return;
pp = poly.GetClosestPointTo(pp, false).TransformBy(ucs);
double par = poly.GetParameterAtPoint(pp);
double dist = poly.GetDistAtPoint(pp);
int idx = (int)par;
Point3d p1 = poly.GetPointAtDist(dist - gap/2).TransformBy(ucs);
Point3d p2 = poly.GetPointAtDist(dist + gap/2).TransformBy(ucs);
poly.AddVertexAt(idx+1, new Point2d(p1.X, p1.Y), 1, 0, 0);
poly.AddVertexAt(idx+2, new Point2d(p2.X, p2.Y), 0, 0, 0);
tr.Commit();
}
} |
|