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

DomCR / ACadSharp / 12905761471

22 Jan 2025 10:03AM UTC coverage: 2.0% (-74.0%) from 75.963%
12905761471

push

github

DomCR
version 1.0.6

104 of 7676 branches covered (1.35%)

Branch coverage included in aggregate %.

590 of 27024 relevant lines covered (2.18%)

5.13 hits per line

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

0.0
/src/ACadSharp/Entities/Entity.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Objects;
3
using ACadSharp.Tables;
4
using CSMath;
5
using System;
6

7
namespace ACadSharp.Entities
8
{
9
        /// <summary>
10
        /// The standard class for a basic CAD entity or a graphical object.
11
        /// </summary>
12
        [DxfSubClass(DxfSubclassMarker.Entity)]
13
        public abstract class Entity : CadObject, IEntity
14
        {
15
                /// <inheritdoc/>
16
                public override string SubclassMarker => DxfSubclassMarker.Entity;
×
17

18
                /// <inheritdoc/>
19
                [DxfCodeValue(DxfReferenceType.Name, 8)]
20
                public Layer Layer
21
                {
22
                        get { return this._layer; }
×
23
                        set
24
                        {
×
25
                                if (value == null)
×
26
                                {
×
27
                                        throw new ArgumentNullException(nameof(value));
×
28
                                }
29

30
                                if (this.Document != null)
×
31
                                {
×
32
                                        this._layer = this.updateTable(value, this.Document.Layers);
×
33
                                }
×
34
                                else
35
                                {
×
36
                                        this._layer = value;
×
37
                                }
×
38
                        }
×
39
                }
40

41
                /// <inheritdoc/>
42
                [DxfCodeValue(62, 420)]
43
                public Color Color { get; set; } = Color.ByLayer;
×
44

45
                /// <inheritdoc/>
46
                [DxfCodeValue(370)]
47
                public LineweightType LineWeight { get; set; } = LineweightType.ByLayer;
×
48

49
                /// <inheritdoc/>
50
                [DxfCodeValue(48)]
51
                public double LinetypeScale { get; set; } = 1.0;
×
52

53
                /// <inheritdoc/>
54
                [DxfCodeValue(60)]
55
                public bool IsInvisible { get; set; } = false;
×
56

57
                /// <inheritdoc/>
58
                [DxfCodeValue(440)]
59
                public Transparency Transparency { get; set; } = Transparency.ByLayer;
×
60

61
                /// <inheritdoc/>
62
                [DxfCodeValue(DxfReferenceType.Name, 6)]
63
                public LineType LineType
64
                {
65
                        get { return this._lineType; }
×
66
                        set
67
                        {
×
68
                                if (value == null)
×
69
                                {
×
70
                                        throw new ArgumentNullException(nameof(value));
×
71
                                }
72

73
                                if (this.Document != null)
×
74
                                {
×
75
                                        this._lineType = this.updateTable(value, this.Document.LineTypes);
×
76
                                }
×
77
                                else
78
                                {
×
79
                                        this._lineType = value;
×
80
                                }
×
81
                        }
×
82
                }
83

84
                /// <inheritdoc/>
85
                [DxfCodeValue(DxfReferenceType.Handle, 347)]
86
                public Material Material { get; set; }
×
87

88
                /// <summary>
89
                /// Book color for this entity.
90
                /// </summary> 
91
                [DxfCodeValue(DxfReferenceType.Name, 430)]
92
                public BookColor BookColor
93
                {
94
                        get { return this._bookColor; }
×
95
                        set
96
                        {
×
97
                                if (this.Document != null)
×
98
                                {
×
99
                                        this._bookColor = this.updateCollection(value, this.Document.Colors);
×
100
                                }
×
101
                                else
102
                                {
×
103
                                        this._bookColor = value;
×
104
                                }
×
105
                        }
×
106
                }
107

108
                private Layer _layer = Layer.Default;
×
109

110
                private LineType _lineType = LineType.ByLayer;
×
111

112
                private BookColor _bookColor = null;
×
113

114
                /// <inheritdoc/>
115
                public Entity() : base() { }
×
116

117
                /// <inheritdoc/>
118
                public abstract BoundingBox GetBoundingBox();
119

120
                /// <inheritdoc/>
121
                public void MatchProperties(IEntity entity)
122
                {
×
123
                        if (entity is null)
×
124
                        {
×
125
                                throw new ArgumentNullException(nameof(entity));
×
126
                        }
127

128
                        if (entity.Handle == 0)
×
129
                        {
×
130
                                entity.Layer = (Layer)this.Layer.Clone();
×
131
                                entity.LineType = (LineType)this.LineType.Clone();
×
132
                        }
×
133
                        else
134
                        {
×
135
                                entity.Layer = this.Layer;
×
136
                                entity.LineType = this.LineType;
×
137
                        }
×
138

139
                        entity.Color = this.Color;
×
140
                        entity.LineWeight = this.LineWeight;
×
141
                        entity.LinetypeScale = this.LinetypeScale;
×
142
                        entity.IsInvisible = this.IsInvisible;
×
143
                        entity.Transparency = this.Transparency;
×
144
                }
×
145

146
                /// <inheritdoc/>
147
                public override CadObject Clone()
148
                {
×
149
                        Entity clone = (Entity)base.Clone();
×
150

151
                        clone.Layer = (Layer)this.Layer.Clone();
×
152
                        clone.LineType = (LineType)this.LineType.Clone();
×
153
                        clone.Material = (Material)this.Material?.Clone();
×
154

155
                        return clone;
×
156
                }
×
157

158
                internal override void AssignDocument(CadDocument doc)
159
                {
×
160
                        base.AssignDocument(doc);
×
161

162
                        this._layer = this.updateTable(this.Layer, doc.Layers);
×
163
                        this._lineType = this.updateTable(this.LineType, doc.LineTypes);
×
164

165
                        doc.Layers.OnRemove += this.tableOnRemove;
×
166
                        doc.LineTypes.OnRemove += this.tableOnRemove;
×
167
                }
×
168

169
                internal override void UnassignDocument()
170
                {
×
171
                        this.Document.Layers.OnRemove -= this.tableOnRemove;
×
172
                        this.Document.LineTypes.OnRemove -= this.tableOnRemove;
×
173

174
                        base.UnassignDocument();
×
175

176
                        this.Layer = (Layer)this.Layer.Clone();
×
177
                        this.LineType = (LineType)this.LineType.Clone();
×
178
                }
×
179

180
                protected virtual void tableOnRemove(object sender, CollectionChangedEventArgs e)
181
                {
×
182
                        if (e.Item.Equals(this.Layer))
×
183
                        {
×
184
                                this.Layer = this.Document.Layers[Layer.DefaultName];
×
185
                        }
×
186

187
                        if (e.Item.Equals(this.LineType))
×
188
                        {
×
189
                                this.LineType = this.Document.LineTypes[LineType.ByLayerName];
×
190
                        }
×
191
                }
×
192
        }
193
}
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