IFoxCad带有撤回的多段线Jig示例
本帖最后由 d1742647821 于 2023-2-9 18:48 编辑带有撤回的多段线Jig示例,帮助大家学习使用IFox
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;
}
}
}
attach://124871.flv
个人B站主页有教学视频,欢迎捧场,点此进入!!!
谢谢楼主分享 没有CAD原创舒服,总感觉一闪一闪的
页:
[1]