明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2033|回复: 3

[基础] 不用JIG技术,模拟cad的简单多段线

[复制链接]
发表于 2011-1-8 19:27 | 显示全部楼层 |阅读模式
只能模拟直线,圆弧还没弄上去:
  1.   public ObjectId CreatePolyLine()
  2.         {
  3.             ObjectId pline_id = new ObjectId();
  4.             Database db = Application.DocumentManager.MdiActiveDocument.Database;
  5.             Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
  6.             PromptPointOptions ppo = new PromptPointOptions("\n请输入第一个点");
  7.             PromptPointResult ppr = ed.GetPoint(ppo);
  8.             Polyline pline = new Polyline();
  9.             if (ppr.Status == PromptStatus.OK)
  10.             {
  11.                 int count = 1;
  12.                 PromptPointOptions ppo_next = new PromptPointOptions("\n请输入下一个点");
  13.                 ppo_next.UseBasePoint = true;
  14.                 ppo_next.BasePoint = ppr.Value;
  15.                 PromptPointResult ppr_next = ed.GetPoint(ppo_next);

  16.                 while (ppr.Status == PromptStatus.OK)
  17.                 {
  18.                     if (count == 1)
  19.                     {

  20.                         #region
  21.                         using (Transaction ts = db.TransactionManager.StartTransaction())
  22.                         {
  23.                             //BlockTable bt = ts.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
  24.                             //BlockTableRecord btr = ts.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
  25.                             pline.AddVertexAt(0, ppr.Value.Convert2d(new Plane()), 0, 0, 0);
  26.                             pline.AddVertexAt(1, ppr_next.Value.Convert2d(new Plane()), 0, 0, 0);
  27.                             pline_id = CreateEntity(pline);
  28.                             ts.Commit();
  29.                         }
  30.                         #endregion
  31.                     }
  32.                     else
  33.                     {
  34.                         #region
  35.                         using (Transaction ts = db.TransactionManager.StartTransaction())
  36.                         {
  37.                             pline = ts.GetObject(pline_id, OpenMode.ForWrite) as Polyline;
  38.                             pline.AddVertexAt(count, ppr_next.Value.Convert2d(new Plane()), 0, 0, 0);
  39.                             //pline_id = CreateEntity(pline);
  40.                             ed.WriteMessage("ok");
  41.                             ts.Commit();
  42.                         }
  43.                         #endregion
  44.                     }
  45.                     count++;
  46.                     ppo_next.UseBasePoint = true;
  47.                     ppo_next.BasePoint = ppr_next.Value;
  48.                     ppr_next = ed.GetPoint(ppo_next);
  49.                 }

  50.             }
  51.             return pline_id;
  52.         }
字符输入控制还没学到位,所以代码还没完整。

评分

参与人数 1金钱 +30 收起 理由
雪山飞狐_lzh + 30 鼓励一下

查看全部评分

发表于 2011-1-8 21:02 | 显示全部楼层
只是GetPoint的话,当然只能模拟直线段,:)
发表于 2011-1-8 21:30 | 显示全部楼层
不错不错
 楼主| 发表于 2011-1-8 21:47 | 显示全部楼层
回复 雪山飞狐_lzh 的帖子

这个概念是在《ObjectARX开发实例教程》转移过来的,之前是学c++arx,也是用这种方法写多段线的,转到在c#环境下,或许可以用这个idea,可惜只学了一个多月,很多东西都没学完整,所以程序就显得简陋了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-20 22:30 , Processed in 0.283257 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表