@@ -9,6 +9,7 @@ namespace IFoxCAD.Cad;
99public static class PolylineEx
1010{
1111 #region 获取多段线端点
12+
1213 /// <summary>
1314 /// 获取二维多段线的端点坐标
1415 /// </summary>
@@ -24,7 +25,6 @@ public static IEnumerable<Point3d> GetPoints(this Polyline2d pl2d)
2425 yield return vertex . Position ;
2526 }
2627 }
27-
2828 }
2929
3030 /// <summary>
@@ -39,7 +39,7 @@ public static IEnumerable<Point3d> GetPoints(this Polyline3d pl3d)
3939 {
4040 if ( tr . GetObject ( id ) is PolylineVertex3d vertex )
4141 yield return vertex . Position ;
42- }
42+ }
4343 }
4444
4545 /// <summary>
@@ -51,13 +51,15 @@ public static List<Point3d> GetPoints(this Polyline pl)
5151 {
5252 return
5353 Enumerable
54- . Range ( 0 , pl . NumberOfVertices )
55- . Select ( pl . GetPoint3dAt )
56- . ToList ( ) ;
54+ . Range ( 0 , pl . NumberOfVertices )
55+ . Select ( pl . GetPoint3dAt )
56+ . ToList ( ) ;
5757 }
58+
5859 #endregion
5960
6061 #region 创建多段线
62+
6163 /// <summary>
6264 /// 根据点集创建多段线<br/>
6365 /// 此多段线无默认全局宽度0,无圆弧段
@@ -69,9 +71,7 @@ public static Polyline CreatePolyline(this IEnumerable<Point3d> points, Action<P
6971 {
7072 Polyline pl = new ( ) ;
7173 pl . SetDatabaseDefaults ( ) ;
72- points . ForEach ( ( index , pt ) => {
73- pl . AddVertexAt ( index , pt . Point2d ( ) , 0 , 0 , 0 ) ;
74- } ) ;
74+ points . ForEach ( ( index , pt ) => { pl . AddVertexAt ( index , pt . Point2d ( ) , 0 , 0 , 0 ) ; } ) ;
7575 action ? . Invoke ( pl ) ;
7676 return pl ;
7777 }
@@ -82,19 +82,21 @@ public static Polyline CreatePolyline(this IEnumerable<Point3d> points, Action<P
8282 /// <param name="pts">端点表,利用元组(Point3d pt, double bulge, double startWidth, double endWidth)</param>
8383 /// <param name="action">轻多段线属性设置委托</param>
8484 /// <returns>轻多段线对象</returns>
85- public static Polyline CreatePolyline ( this IEnumerable < ( Point3d pt , double bulge , double startWidth , double endWidth ) > pts ,
86- Action < Polyline > ? action = null )
85+ public static Polyline CreatePolyline (
86+ this IEnumerable < ( Point3d pt , double bulge , double startWidth , double endWidth ) > pts ,
87+ Action < Polyline > ? action = null )
8788 {
8889 Polyline pl = new ( ) ;
8990 pl . SetDatabaseDefaults ( ) ;
9091
91- pts . ForEach ( ( index , vertex ) => {
92+ pts . ForEach ( ( index , vertex ) =>
93+ {
9294 pl . AddVertexAt ( index , vertex . pt . Point2d ( ) , vertex . bulge , vertex . startWidth , vertex . endWidth ) ;
9395 } ) ;
9496 action ? . Invoke ( pl ) ;
9597 return pl ;
9698 }
97-
99+
98100 /// <summary>
99101 /// 根据Extents3d创建多段线<br/>
100102 /// 此多段线无默认全局宽度0,无圆弧段,标高为0
@@ -111,15 +113,12 @@ public static Polyline CreatePolyline(this Extents3d points, Action<Polyline>? a
111113 points . MaxPoint . Point2d ( ) ,
112114 new ( points . MaxPoint . X , points . MinPoint . Y )
113115 } ;
114- Polyline pl = new ( ) ;
116+ Polyline pl = new ( ) { Closed = true } ;
115117 pl . SetDatabaseDefaults ( ) ;
116- pts . ForEach ( ( index , pt ) => {
117- pl . AddVertexAt ( index , pt , 0 , 0 , 0 ) ;
118- } ) ;
118+ pts . ForEach ( ( index , pt ) => { pl . AddVertexAt ( index , pt , 0 , 0 , 0 ) ; } ) ;
119119 action ? . Invoke ( pl ) ;
120120 return pl ;
121- }
121+ }
122122
123123 #endregion
124-
125124}
0 commit comments