不用JIG技术,模拟cad的简单多段线
只能模拟直线,圆弧还没弄上去:public ObjectId CreatePolyLine()
{
ObjectId pline_id = new ObjectId();
Database db = Application.DocumentManager.MdiActiveDocument.Database;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptPointOptions ppo = new PromptPointOptions("\n请输入第一个点");
PromptPointResult ppr = ed.GetPoint(ppo);
Polyline pline = new Polyline();
if (ppr.Status == PromptStatus.OK)
{
int count = 1;
PromptPointOptions ppo_next = new PromptPointOptions("\n请输入下一个点");
ppo_next.UseBasePoint = true;
ppo_next.BasePoint = ppr.Value;
PromptPointResult ppr_next = ed.GetPoint(ppo_next);
while (ppr.Status == PromptStatus.OK)
{
if (count == 1)
{
#region
using (Transaction ts = db.TransactionManager.StartTransaction())
{
//BlockTable bt = ts.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
//BlockTableRecord btr = ts.GetObject(bt, OpenMode.ForWrite) as BlockTableRecord;
pline.AddVertexAt(0, ppr.Value.Convert2d(new Plane()), 0, 0, 0);
pline.AddVertexAt(1, ppr_next.Value.Convert2d(new Plane()), 0, 0, 0);
pline_id = CreateEntity(pline);
ts.Commit();
}
#endregion
}
else
{
#region
using (Transaction ts = db.TransactionManager.StartTransaction())
{
pline = ts.GetObject(pline_id, OpenMode.ForWrite) as Polyline;
pline.AddVertexAt(count, ppr_next.Value.Convert2d(new Plane()), 0, 0, 0);
//pline_id = CreateEntity(pline);
ed.WriteMessage("ok");
ts.Commit();
}
#endregion
}
count++;
ppo_next.UseBasePoint = true;
ppo_next.BasePoint = ppr_next.Value;
ppr_next = ed.GetPoint(ppo_next);
}
}
return pline_id;
}
字符输入控制还没学到位,所以代码还没完整。 只是GetPoint的话,当然只能模拟直线段,:) 不错不错 回复 雪山飞狐_lzh 的帖子
这个概念是在《ObjectARX开发实例教程》转移过来的,之前是学c++arx,也是用这种方法写多段线的,转到在c#环境下,或许可以用这个idea,可惜只学了一个多月,很多东西都没学完整,所以程序就显得简陋了
页:
[1]