• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 26649554716

29 May 2026 04:35PM UTC coverage: 77.276% (+0.3%) from 76.999%
26649554716

Pull #1076

github

web-flow
Merge 0259bb30c into 2addb6ad2
Pull Request #1076: Add JSON serialization support for CadObject instances

8698 of 12225 branches covered (71.15%)

Branch coverage included in aggregate %.

294 of 322 new or added lines in 14 files covered. (91.3%)

3 existing lines in 2 files now uncovered.

31454 of 39734 relevant lines covered (79.16%)

156366.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/src/ACadSharp/Entities/LwPolyLine.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Extensions;
3
using CSMath;
4
using CSUtilities.Extensions;
5
using System.Collections.Generic;
6
using System.Linq;
7

8
namespace ACadSharp.Entities;
9

10
/// <summary>
11
/// Represents a <see cref="LwPolyline"/> entity
12
/// </summary>
13
/// <remarks>
14
/// Object name <see cref="DxfFileToken.EntityLwPolyline"/> <br/>
15
/// Dxf class name <see cref="DxfSubclassMarker.LwPolyline"/>
16
/// </remarks>
17
[DxfName(DxfFileToken.EntityLwPolyline)]
18
[DxfSubClass(DxfSubclassMarker.LwPolyline)]
19
public partial class LwPolyline : Entity, IPolyline
20
{
21
        /// <summary>
22
        /// Constant width
23
        /// </summary>
24
        /// <remarks>
25
        /// Not used if variable width (codes 40 and/or 41) is set
26
        /// </remarks>
27
        [DxfCodeValue(43)]
28
        public double ConstantWidth { get; set; } = 0.0;
13,248✔
29

30
        /// <summary>
31
        /// The current elevation of the object.
32
        /// </summary>
33
        [DxfCodeValue(38)]
34
        public double Elevation { get; set; } = 0.0;
9,007✔
35

36
        /// <summary>
37
        /// Polyline flags.
38
        /// </summary>
39
        [DxfCodeValue(70)]
40
        public LwPolylineFlags Flags { get => this._flags; set => this._flags = value; }
11,216✔
41

42
        /// <inheritdoc/>
43
        public bool IsClosed
44
        {
45
                get
46
                {
49✔
47
                        return this.Flags.HasFlag(LwPolylineFlags.Closed);
49✔
48
                }
49✔
49
                set
50
                {
57✔
51
                        if (value)
57✔
52
                        {
44✔
53
                                _flags.AddFlag(LwPolylineFlags.Closed);
44✔
54
                        }
44✔
55
                        else
56
                        {
13✔
57
                                _flags.RemoveFlag(LwPolylineFlags.Closed);
13✔
58
                        }
13✔
59
                }
57✔
60
        }
61

62
        /// <summary>
63
        /// Specifies the three-dimensional normal unit vector for the object.
64
        /// </summary>
65
        [DxfCodeValue(210, 220, 230)]
66
        public XYZ Normal { get; set; } = XYZ.AxisZ;
9,016✔
67

68
        /// <inheritdoc/>
69
        public override string ObjectName => DxfFileToken.EntityLwPolyline;
22,547✔
70

71
        /// <inheritdoc/>
72
        public override ObjectType ObjectType => ObjectType.LWPOLYLINE;
41✔
73

74
        /// <inheritdoc/>
75
        public override string SubclassMarker => DxfSubclassMarker.LwPolyline;
36,289✔
76

77
        /// <summary>
78
        /// Specifies the distance a 2D object is extruded above or below its elevation.
79
        /// </summary>
80
        [DxfCodeValue(39)]
81
        public double Thickness { get; set; } = 0.0;
9,016✔
82

83
        /// <summary>
84
        /// Vertices that form this LwPolyline
85
        /// </summary>
86
        [DxfCodeValue(DxfReferenceType.Count, 90)]
87
        public List<Vertex> Vertices { get; private set; } = new List<Vertex>();
145,524✔
88

89
        /// <inheritdoc/>
90
        IEnumerable<IVertex> IPolyline.Vertices { get { return this.Vertices; } }
3,231✔
91

92
        private LwPolylineFlags _flags;
93

94
        /// <inheritdoc/>
95
        public LwPolyline() : base() { }
25,284✔
96

97
        /// <summary>
98
        /// Initializes a new instance of the <see cref="LwPolyline"/> class with the specified vertices.
99
        /// </summary>
100
        /// <remarks>The provided <paramref name="vertices"/> are added to the polyline in the order they appear in
101
        /// the collection.</remarks>
102
        /// <param name="vertices">A collection of <see cref="Vertex"/> objects that define the vertices of the polyline.</param>
103
        public LwPolyline(params IEnumerable<Vertex> vertices)
33✔
104
        {
33✔
105
                this.Vertices.AddRange(vertices);
33✔
106
        }
33✔
107

108
        /// <summary>
109
        /// Initializes a new instance of the <see cref="LwPolyline"/> class with the specified vertices.
110
        /// </summary>
111
        /// <remarks>This constructor allows you to create a lightweight polyline by specifying its vertices as a
112
        /// collection of <see cref="XY"/> points. The vertices are internally converted to <see cref="Vertex"/>
113
        /// objects.</remarks>
114
        /// <param name="vertices">A collection of <see cref="XY"/> points representing the vertices of the polyline. Each point defines a vertex in
115
        /// the order it appears in the collection.</param>
116
        public LwPolyline(params IEnumerable<IVector> vertices)
NEW
117
                : this(vertices.Select(v => new Vertex(v.Convert<XY>()))) { }
×
118

119
        /// <inheritdoc/>
120
        public override void ApplyTransform(Transform transform)
121
        {
×
122
                var newNormal = this.transformNormal(transform, this.Normal);
×
123

124
                this.getWorldMatrix(transform, this.Normal, newNormal, out Matrix3 transOW, out Matrix3 transWO);
×
125

126
                foreach (var vertex in this.Vertices)
×
127
                {
×
128
                        XYZ v = transOW * vertex.Location.Convert<XYZ>();
×
129
                        v = transform.ApplyTransform(v);
×
130
                        v = transWO * v;
×
131
                        vertex.Location = v.Convert<XY>();
×
132
                }
×
133

134
                this.Normal = newNormal;
×
135
        }
×
136

137
        /// <inheritdoc/>
138
        public override CadObject Clone()
139
        {
83✔
140
                LwPolyline clone = (LwPolyline)base.Clone();
83✔
141

142
                clone.Vertices = new List<Vertex>();
83✔
143
                foreach (var v in this.Vertices)
969✔
144
                {
360✔
145
                        clone.Vertices.Add(v.Clone());
360✔
146
                }
360✔
147
                return clone;
83✔
148
        }
83✔
149

150
        /// <inheritdoc/>
151
        public override BoundingBox GetBoundingBox()
152
        {
8✔
153
                if (this.Vertices.Any(v => v.Bulge != 0))
40!
154
                {
×
155
                        return BoundingBox.FromPoints(this.GetPoints<XYZ>(byte.MaxValue));
×
156
                }
157

158
                return BoundingBox.FromPoints(this.Vertices.Select(v => v.Location.Convert<XYZ>()));
40✔
159
        }
8✔
160
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc