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

   

  }
相关推荐
刘欣的博客2 小时前
C# CS架构程序发版升级的走数据库方案
c#·单文件升级自己的方式
Yorlen_Zhang4 小时前
Python Tkinter Text 控件完全指南:从基础编辑器到富文本应用
开发语言·python·c#
不绝1914 小时前
C#进阶:预处理指令/反射,Gettype,Typeof/关键类
开发语言·c#
大鹏说大话4 小时前
告别 MSBuild 脚本混乱:用 C# 和 Nuke 构建清晰、可维护的现代化构建系统
开发语言·c#
czhc11400756635 小时前
通信 28
c#
雨中风华6 小时前
Linux, macOS系统实现远程目录访问(等同于windows平台xFsRedir软件的目录重定向)
linux·windows·macos
yuuki2332338 小时前
【C++】继承
开发语言·c++·windows
非凡ghost8 小时前
PowerDirector安卓版(威力导演安卓版)
android·windows·学习·软件需求
bugcome_com9 小时前
C# 程序结构详解:从 Hello World 开始
c#
唐梓航-求职中10 小时前
编程-技术-算法-leetcode-288. 单词的唯一缩写
算法·leetcode·c#