032集——圆转多段线(Circle to Polyline)(CAD—C#二次开发入门)

CAD中圆可转为带有凸度的多段线以方便后期数据计算、处理,效果如下:

白色为圆,红色为转换后的多段线(为区分,已手工偏移多段线)

cs 复制代码
  public static  void XX()
  {
      var curves = Z.db.SelectEntities<Entity>();
      foreach (var item in curves)
      {
          if (item is Circle)
          {
              Circle temp = (Circle)item;
              Point3d pt = temp.Center;
              double leftx = pt.X - temp.Radius;
              double rightx = pt.X + temp.Radius;
              double topx = pt.X;
              double bottomx = pt.X;
              double lefty = pt.Y;
              double righty = pt.Y;
              double topy = pt.Y + temp.Radius;
              double bottomy = pt.Y - temp.Radius;
              Point2d left = new Point2d(leftx, lefty);
              Point2d right = new Point2d(rightx, righty);
              Point2d top = new Point2d(topx, topy);
              Point2d bottom = new Point2d(bottomx, bottomy);
              Polyline pl = new Polyline();
              pl.AddVertexAt(0, bottom, 1, 0, 0);
              pl.AddVertexAt(1, top, 1, 0, 0);
              pl.AddVertexAt(2, bottom, 0, 0, 0);
              pl.ColorIndex = 1;
              Z.db.AddEntityToModeSpace(pl);
              pl.Highlight();
              // Debugger.Break();
          }
          //else
          //{
          //    Z.db.Erase(item);
          //}
      }
     

   

  }
相关推荐
唐宋元明清21885 小时前
.NET Win32磁盘动态卷/跨区卷触发“函数不正确”问题排查
windows·c#·存储
hez20106 小时前
Satori GC:同时做到高吞吐、低延时和低内存占用
c#·.net·.net core·gc·clr
唐青枫1 天前
C#.NET Channel 深入解析:高性能异步生产者消费者模型实战
c#·.net
小峥降临2 天前
Rokid UXR 的手势追踪虚拟中更真实的手实战开发【含 工程源码 和 最终完成APK】
c#
晨星shine6 天前
GC、Dispose、Unmanaged Resource 和 Managed Resource
后端·c#
用户298698530146 天前
.NET 文档自动化:Spire.Doc 设置奇偶页页眉/页脚的最佳实践
后端·c#·.net
用户3667462526746 天前
接口文档汇总 - 2.设备状态管理
c#
用户3667462526746 天前
接口文档汇总 - 3.PLC通信管理
c#
Ray Liang7 天前
用六边形架构与整洁架构对比是伪命题?
java·python·c#·架构设计
阿白的白日梦7 天前
winget基础管理---更新/修改源为国内源
windows