- 积分
- 9376
- 明经币
- 个
- 注册时间
- 2021-11-26
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 d1742647821 于 2023-2-9 18:48 编辑
带有撤回的多段线Jig示例,帮助大家学习使用IFox
- [CommandMethod("DrawPolyline")]
- public static void DrawPolyline()
- {
- using var tr = new DBTrans();
- var ed = Env.Editor;
- var r1 = ed.GetPoint("\n选择起点");
- if (r1.Status != PromptStatus.OK)
- return;
- var pt1 = r1.Value.Ucs2Wcs().Point2d();
- var pl = new Polyline();
- pl.AddVertexAt(0, pt1, 0, 0, 0);
- pl.AddVertexAt(1, pt1, 0, 0, 0);
- pl.SetDatabaseDefaults();
- using var jig = new JigEx((mp, _) =>
- {
- pl.SetPointAt(pl.NumberOfVertices - 1, mp.Point2d());
- });
- jig.DatabaseEntityDraw(wd => wd.Geometry.Draw(pl));
- var jppo= jig.SetOptions(pl.GetPoint3dAt(pl.NumberOfVertices - 1), CursorType.Crosshair, "\n选择下一点");
- jppo.Keywords.Add("U", "U", "撤回(U)");
- while (true)
- {
- jppo.BasePoint = pl.GetPoint3dAt(pl.NumberOfVertices - 1);
- var r2 = ed.Drag(jig);
- if (r2.Status == PromptStatus.OK)
- {
- pl.AddVertexAt(pl.NumberOfVertices, jig.MousePointWcsLast.Point2d(), 0, 0, 0);
- }
- else if (r2.Status == PromptStatus.Keyword)
- {
- switch (r2.StringResult.ToUpper())
- {
- case "U":
- if (pl.NumberOfVertices > 2)
- {
- pl.RemoveVertexAt(pl.NumberOfVertices - 2);
- }
- break;
- }
- }
- else
- {
- if(pl.NumberOfVertices > 2)
- {
- pl.RemoveVertexAt(pl.NumberOfVertices - 1);
- tr.CurrentSpace.AddEntity(pl);
- }
- return;
- }
- }
- }
个人B站主页有教学视频,欢迎捧场,点此进入!!!
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
评分
-
查看全部评分
|