AutoCAD C# 读取Hatch边界

编程入门 行业动态 更新时间:2024-10-18 10:37:39

AutoCAD C# 读取Hatch<a href=https://www.elefans.com/category/jswz/34/1761295.html style=边界"/>

AutoCAD C# 读取Hatch边界

        /// 填充边界提取转化方法/// </summary>/// <param name="hat">需要转化的Hatch对象</param>/// <param name="trans">声明的事务对象</param>/// <param name="btr">数据库中的模型空间</param>public static void DrawBorder(Hatch hatch, Transaction trans, BlockTableRecord btr){//取得边界数Point2dCollection col_point2d = new Point2dCollection();Curve2dCollection col_cur2d = new Curve2dCollection();// i=0 时 是外轮廓线,其他为内轮廓线for (int i = 0; i < hatch.NumberOfLoops; i++){col_point2d.Clear();HatchLoop hatLoop = null;try{hatLoop = hatch.GetLoopAt(i);}catch (System.Exception ex){continue;}col_cur2d = hatLoop.Curves;foreach (Curve2d curve2d in col_cur2d){// 曲线分成多少段int numSample = 2;if (curve2d.GetType().Name != "LineSegment2d")  {// 如果不是直线,则计算需要制造多少段// 获取曲线的间隔(上、下界)Interval interval = curve2d.GetInterval();   double curveLength = curve2d.GetLength(interval.LowerBound, interval.UpperBound);numSample = (int)(curveLength / 0.1);if (numSample < 36){numSample = 36;}if (numSample > 360){numSample = 360;}}Point2d[] M_point2d = curve2d.GetSamplePoints(numSample);foreach (Point2d point in M_point2d){if (!col_point2d.Contains(point))col_point2d.Add(point);}}// 根据获得的Point2d点集创建闭合PolylinePolyline polyline = new Polyline();polyline.Closed = true;polyline.Color = hatch.Color;CreatePolyline(polyline, col_point2d);btr.AppendEntity(polyline);trans.AddNewlyCreatedDBObject(polyline, true);}}public static void CreatePolyline(Polyline polylineResult , Point2dCollection col_point2d){for (int i = 0; i < col_point2d.Count; i++){Point2d point = col_point2d[i];polylineResult.AddVertexAt(polylineResult.NumberOfVertices, point, 0, 0, 0);}}

参考来源:

C#CAD二次开发图案填充对象边界提取_北辰之北灬的博客-CSDN博客

AutoCAD_C#Net获取图案填充的边界线.docx_c#dxfsolid边界-C#代码类资源-CSDN下载

更多推荐

AutoCAD C# 读取Hatch边界

本文发布于:2024-02-10 21:40:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1677434.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:边界   AutoCAD   Hatch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!