乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 33|回复: 0

获取多段线的顶点坐标. 欢迎拍砖,新手代码

[复制链接]

26

主题

281

帖子

8

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
385
发表于 2015-8-10 22:06:00 | 显示全部楼层 |阅读模式
  1.         [CommandMethod("tt")]
  2.         public void tt()
  3.         {
  4.             Document doc = Autodesk..ApplicationServices.Application.DocumentManager.MdiActiveDocument;
  5.             Database db = HostApplicationServices.WorkingDatabase;
  6.             Editor ed = doc.Editor;
  7.             PromptEntityOptions enOpts = new PromptEntityOptions("选择一个多段线");
  8.             PromptEntityResult enRes = ed.GetEntity(enOpts);
  9.             if (enRes.Status == PromptStatus.OK)
  10.             {
  11.                 //绘图事物
  12.                 using (Transaction trans = db.TransactionManager.StartTransaction())
  13.                 {
  14.                     Entity en = (Entity)trans.GetObject(enRes.ObjectId, OpenMode.ForRead);
  15.                     if (en is Polyline)
  16.                     {
  17.                         Polyline pl = (Polyline)en;
  18.                         int pts_len = pl.NumberOfVertices;
  19.                         for (int i = 0; i
  20.         /// 获取多段线的顶点
  21.         ///
  22.         /// 多段线对象
  23.         public static Point3dCollection GetPolyPoints(this Polyline pline)
  24.         {
  25.             Point3dCollection pts = new Point3dCollection();
  26.             int i;
  27.             for (i = 0; i < pline.NumberOfVertices; i++)
  28.             {
  29.                 Point3d pt = pline.GetPoint3dAt(i);
  30.                 pts.Add(pt);
  31.             }
  32.             return pts;
  33.         }
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 11:21 , Processed in 0.439632 second(s), 65 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表