只能模拟直线,圆弧还没弄上去:
- 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[BlockTableRecord.ModelSpace], 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;
- }
字符输入控制还没学到位,所以代码还没完整。 |