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);
          //}
      }
     

   

  }
相关推荐
qyhua27 分钟前
Windows 平台源码部署 Dify教程(不依赖 Docker)
人工智能·windows·python
SAJalon1 小时前
C#集合全面解析
c#
女程序猿!!!2 小时前
网址收集总结
windows
SAJalon3 小时前
C#数组全面解析
c#
henreash3 小时前
xLua和C#交互
开发语言·c#·交互
love530love4 小时前
Windows 如何更改 ModelScope 的模型下载缓存位置?
运维·人工智能·windows·python·缓存·modelscope
Leinwin5 小时前
微软Fabric重塑数据管理:Forrester报告揭示高ROI
运维·microsoft·fabric
正宗咸豆花6 小时前
在 Azure 中配置 SMS 与 OTP
microsoft·flask·azure
weixin_3077791310 小时前
Windows 11下纯软件模拟虚拟机的设备模拟与虚拟化(仅终端和网络)
windows·系统架构
tanak12 小时前
2025年7月23日 AI 今日头条
人工智能·microsoft