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

   

  }
相关推荐
雨落倾城夏未凉3 天前
第四章c#方法-参数数组和可选参数(16)
后端·c#
唐青枫4 天前
线程不是越多越快:C#.NET Thread 生命周期、同步与后台工作线程实战
c#·.net
唐青枫5 天前
别只会反射:C#.NET Emit 动态生成代码实战详解
c#·.net
咕白m6255 天前
.NET 环境下 Word 超链接批量提取方案
c#·.net
用户91721561902115 天前
C# 通信协议增量解析:用状态机处理半包和粘包
c#
小码编匠6 天前
C# 工控上位机必备:数据转换工具类与十个核心模块
后端·c#·.net
唐青枫8 天前
别再乱用 StartNew:C#.NET TaskFactory 任务调度实战详解
c#·.net
Artech8 天前
[MAF预定义的AIContextProvider-03]ChatHistoryMemoryProvider——赋予Agent从经验中学习的能力
ai·c#·agent·memory·maf
Scout-leaf10 天前
C#摸鱼实录——IoC与DI案例详解
c#
咕白m62510 天前
使用 C# 在 Excel 中应用多种字体样式
后端·c#