scf0413 发表于 2011-1-10 21:20:00

拾取点时出现的问题

请教斑竹 在点取坐标的时候 怎样用一个循环语句 可以一直点取 直到确定为止,显示在命令行里?

雪山飞狐_lzh 发表于 2011-1-11 09:58:00


仔细看下这两天的帖子,有这方面的代码:
      
      public static void Test2()
      {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            var optPt = new PromptPointOptions("\n选择第一点");
            optPt.AllowNone = true;
            var resPt = ed.GetPoint(optPt);
            optPt.Message = "\n选择下一点";
            optPt.UseBasePoint = true;
            while (resPt.Status == PromptStatus.OK)
            {
                optPt.BasePoint = resPt.Value;
                resPt = ed.GetPoint(optPt);
            }
      }

scf0413 发表于 2011-1-11 14:58:00

飞狐大哥 下面这段代码加个循环 ,该怎么编? 先谢谢了

public void Pickpt()
      {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Point3d pt = Pick("\n 拾取点");
            ed.WriteMessage("\n{0:f1}", pt);
      }
      public static Point3d Pick(string word)
      {
          Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
          Editor ed = doc.Editor;
          PromptPointResult pt = ed.GetPoint(word);
          if (pt.Status == PromptStatus.OK)
          {
            return (Point3d)pt.Value;
          }
          else
          {
            return new Point3d();
          }
      }

epwt 发表于 2011-1-11 15:57:00


public void Pickpt()
{
   Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
   Point3d pt = Pick("\n 拾取点");
   ed.WriteMessage("\n{0:f1}", pt);
}
public static Point3d Pick(string word)
{
   Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
   Editor ed = doc.Editor;
   PromptPointResult pt = ed.GetPoint(word);
   bool isSelected = false;
   while (!isSelected) {
    if (pt.Status == PromptStatus.OK) {
   isSelected = true;
   return (Point3d)pt.Value;
    } else {
   continue;
    }
   }
希望会对你有用。

scf0413 发表于 2011-1-11 16:27:00

还是不能连续点取么?

epwt 发表于 2011-1-11 17:21:00

把返回类型改成point3dCollection,
用选择集来获取选中的点试试。
不过你得获得用户什么时候取消选择了。

scf0413 发表于 2011-1-11 19:42:00

我的目的是在cad中连续点取任意实体上的坐标,我是初学者,还望高手能帮帮忙。不过还是要谢谢 epwt

scf0413 发表于 2011-1-11 21:26:00

恳请斑竹 帮帮我这个初学者 谢谢

雪山飞狐_lzh 发表于 2011-1-11 22:07:00

这个,还是看不懂你的要求,说明清楚点?
如果有必要,贴图说明下吧
页: [1]
查看完整版本: 拾取点时出现的问题