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

DomCR / ACadSharp / 22056180537

16 Feb 2026 08:56AM UTC coverage: 77.283% (-0.3%) from 77.593%
22056180537

Pull #978

github

web-flow
Merge a338464f1 into ae77202b7
Pull Request #978: issue-976 context data

8169 of 11454 branches covered (71.32%)

Branch coverage included in aggregate %.

87 of 256 new or added lines in 16 files covered. (33.98%)

13 existing lines in 5 files now uncovered.

29543 of 37343 relevant lines covered (79.11%)

150779.69 hits per line

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

85.51
/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.Objects.cs
1
using ACadSharp.IO.Templates;
2
using ACadSharp.Objects;
3
using ACadSharp.Objects.Evaluations;
4

5
namespace ACadSharp.IO.DWG;
6

7
internal partial class DwgObjectReader : DwgSectionIO
8
{
9
        private void readAnnotScaleObjectContextData(CadAnnotScaleObjectContextDataTemplate template)
NEW
10
        {
×
NEW
11
                this.readObjectContextData(template);
×
12

NEW
13
                template.ScaleHandle = this.handleReference();
×
NEW
14
        }
×
15

16
        private CadTemplate readBlkRefObjectContextData()
NEW
17
        {
×
NEW
18
                BlockReferenceObjectContextData contextData = new BlockReferenceObjectContextData();
×
NEW
19
                CadAnnotScaleObjectContextDataTemplate template = new CadAnnotScaleObjectContextDataTemplate(contextData);
×
20

NEW
21
                this.readAnnotScaleObjectContextData(template);
×
22

NEW
23
                contextData.Rotation = this._mergedReaders.ReadBitDouble();
×
NEW
24
                contextData.InsertionPoint = this._mergedReaders.Read3BitDouble();
×
NEW
25
                contextData.XScale = this._mergedReaders.ReadBitDouble();
×
NEW
26
                contextData.YScale = this._mergedReaders.ReadBitDouble();
×
NEW
27
                contextData.ZScale = this._mergedReaders.ReadBitDouble();
×
28

NEW
29
                return template;
×
NEW
30
        }
×
31

32
        private CadTemplate readMTextAttributeObjectContextData()
NEW
33
        {
×
34
                //TODO: MTextAttributeObjectContextData for dwg
NEW
35
                MTextAttributeObjectContextData contextData = new();
×
NEW
36
                CadAnnotScaleObjectContextDataTemplate template = new CadAnnotScaleObjectContextDataTemplate(contextData);
×
37

NEW
38
                this.readAnnotScaleObjectContextData(template);
×
39

NEW
40
                return null;
×
NEW
41
        }
×
42

43
        private void readBlock1PtParameter(CadBlock1PtParameterTemplate template)
44
        {
134✔
45
                this.readBlockParameter(template);
134✔
46

47
                //1010 1020 1030
48
                template.Block1PtParameter.Location = this._mergedReaders.Read3BitDouble();
134✔
49
                //170
50
                template.Block1PtParameter.Value170 = this._mergedReaders.ReadBitShort();
134✔
51
                //171
52
                template.Block1PtParameter.Value171 = this._mergedReaders.ReadBitShort();
134✔
53
                //93
54
                template.Block1PtParameter.Value93 = this._mergedReaders.ReadBitLong();
134✔
55
        }
134✔
56

57
        private void readBlock2PtParameter(CadBlock2PtParameterTemplate template)
58
        {
1✔
59
                this.readBlockParameter(template);
1✔
60

61
                //1010 1020 1030
62
                template.Block2PtParameter.FirstPoint = this._mergedReaders.Read3BitDouble();
1✔
63
                //1011 1021 1031
64
                template.Block2PtParameter.SecondPoint = this._mergedReaders.Read3BitDouble();
1✔
65

66
                //170 (always 4)
67
                for (int i = 0; i < 4; i++)
10✔
68
                {
4✔
69
                        //171 172 173 174
70
                        short n = this._mergedReaders.ReadBitShort();
4✔
71
                        for (int j = 0; j < n; j++)
12✔
72
                        {
2✔
73
                                //94 95 (I guess 96 97)
74
                                var d = this._mergedReaders.ReadBitLong();
2✔
75
                                //303 304
76
                                var e = this._mergedReaders.ReadVariableText();
2✔
77
                        }
2✔
78
                }
4✔
79

80
                for (int k = 0; k < 4; k++)
10✔
81
                {
4✔
82
                        //91 values
83
                        var f = this._mergedReaders.ReadBitLong();
4✔
84
                }
4✔
85

86
                var value177 = this._mergedReaders.ReadBitShort();
1✔
87
        }
1✔
88

89
        private void readBlockAction(CadBlockActionTemplate template)
90
        {
1✔
91
                this.readBlockElement(template);
1✔
92

93
                BlockAction blockAction = template.BlockAction;
1✔
94

95
                // 1010, 1020, 1030
96
                blockAction.ActionPoint = this._mergedReaders.Read3BitDouble();
1✔
97

98
                //71
99
                short entityCount = this._objectReader.ReadBitShort();
1✔
100
                for (int i = 0; i < entityCount; i++)
4✔
101
                {
1✔
102
                        ulong entityHandle = this.handleReference();
1✔
103
                        template.EntityHandles.Add(entityHandle);
1✔
104
                }
1✔
105

106
                // 70
107
                blockAction.Value70 = this._mergedReaders.ReadBitShort();
1✔
108
        }
1✔
109

110
        private void readBlockActionBasePt(CadBlockActionBasePtTemplate template)
111
        {
1✔
112
                this.readBlockAction(template);
1✔
113

114
                BlockActionBasePt blockActionBasePt = template.CadObject as BlockActionBasePt;
1✔
115

116
                blockActionBasePt.Value1011 = this._mergedReaders.Read3BitDouble();
1✔
117

118
                blockActionBasePt.Value92 = this._mergedReaders.ReadBitLong();
1✔
119
                blockActionBasePt.Value301 = this._mergedReaders.ReadVariableText();
1✔
120
                blockActionBasePt.Value93 = this._mergedReaders.ReadBitLong();
1✔
121
                blockActionBasePt.Value302 = this._mergedReaders.ReadVariableText();
1✔
122

123
                blockActionBasePt.Value280 = this._mergedReaders.ReadBit();
1✔
124
                blockActionBasePt.Value1012 = this._mergedReaders.Read3BitDouble();
1✔
125
        }
1✔
126

127
        private void readBlockElement(CadBlockElementTemplate template)
128
        {
271✔
129
                this.readEvaluationExpression(template);
271✔
130

131
                //300 name
132
                template.BlockElement.ElementName = this._mergedReaders.ReadVariableText();
271✔
133
                //98
134
                template.BlockElement.Value98 = this._mergedReaders.ReadBitLong();
271✔
135
                //99
136
                template.BlockElement.Value99 = this._mergedReaders.ReadBitLong();
271✔
137
                //1071
138
                template.BlockElement.Value1071 = this._mergedReaders.ReadBitLong();
271✔
139
        }
271✔
140

141
        private void readBlockGrip(CadBlockGripTemplate template)
142
        {
135✔
143
                this.readBlockElement(template);
135✔
144

145
                var blockGrip = template.CadObject as BlockGrip;
135✔
146

147
                blockGrip.Value91 = this._mergedReaders.ReadBitLong();
135✔
148
                blockGrip.Value92 = this._mergedReaders.ReadBitLong();
135✔
149
                blockGrip.Location = this._mergedReaders.Read3BitDouble();
135✔
150
                blockGrip.Value280 = this._mergedReaders.ReadBitAsShort();
135✔
151
                blockGrip.Value93 = this._mergedReaders.ReadBitLong();
135✔
152
        }
135✔
153

154
        private CadTemplate readBlockGripLocationComponent()
155
        {
804✔
156
                BlockGripExpression gripExpression = new BlockGripExpression();
804✔
157
                CadBlockGripExpressionTemplate template = new CadBlockGripExpressionTemplate(gripExpression);
804✔
158

159
                this.readEvaluationExpression(template);
804✔
160

161
                return template;
804✔
162
        }
804✔
163

164
        private void readBlockParameter(CadBlockParameterTemplate template)
165
        {
135✔
166
                this.readBlockElement(template);
135✔
167

168
                //280
169
                template.BlockParameter.Value280 = this._mergedReaders.ReadBit();
135✔
170
                //281
171
                template.BlockParameter.Value281 = this._mergedReaders.ReadBit();
135✔
172
        }
135✔
173

174
        private CadTemplate readBlockRepresentationData()
175
        {
275✔
176
                BlockRepresentationData representation = new BlockRepresentationData();
275✔
177
                CadBlockRepresentationDataTemplate template = new CadBlockRepresentationDataTemplate(representation);
275✔
178

179
                this.readCommonNonEntityData(template);
275✔
180

181
                representation.Value70 = this._mergedReaders.ReadBitShort();
275✔
182
                template.BlockHandle = this.handleReference();
275✔
183

184
                return template;
275✔
185
        }
275✔
186

187
        private CadTemplate readBlockRotateAction()
188
        {
1✔
189
                BlockRotationAction rotationAction = new();
1✔
190
                CadBlockRotationActionTemplate template = new(rotationAction);
1✔
191

192
                this.readBlockActionBasePt(template);
1✔
193

194
                rotationAction.Value94 = this._mergedReaders.ReadBitLong();
1✔
195
                rotationAction.Value303 = this._mergedReaders.ReadVariableText();
1✔
196

197
                return template;
1✔
198
        }
1✔
199

200
        private CadTemplate readBlockRotationParameter()
201
        {
1✔
202
                BlockRotationParameter blockRotationParameter = new();
1✔
203
                CadBlockRotationParameterTemplate template = new CadBlockRotationParameterTemplate(blockRotationParameter);
1✔
204

205
                this.readBlock2PtParameter(template);
1✔
206

207
                //1011 1021 1031
208
                blockRotationParameter.Point = this._mergedReaders.Read3BitDouble();
1✔
209
                //305
210
                blockRotationParameter.Name = this._mergedReaders.ReadVariableText();
1✔
211
                //306
212
                blockRotationParameter.Description = this._mergedReaders.ReadVariableText();
1✔
213
                //140
214
                blockRotationParameter.NameOffset = this._mergedReaders.ReadBitDouble();
1✔
215

216
                //307 missing text?
217

218
                blockRotationParameter.Value96 = this._mergedReaders.ReadBitLong();
1✔
219
                blockRotationParameter.Value141 = this._mergedReaders.ReadBitDouble();
1✔
220
                blockRotationParameter.Value142 = this._mergedReaders.ReadBitDouble();
1✔
221
                blockRotationParameter.Value143 = this._mergedReaders.ReadBitDouble();
1✔
222

223
                blockRotationParameter.Value175 = this._mergedReaders.ReadBitLong();
1✔
224

225
                return template;
1✔
226
        }
1✔
227

228
        private CadTemplate readBlockVisibilityParameter()
229
        {
134✔
230
                BlockVisibilityParameter blockVisibilityParameter = new BlockVisibilityParameter();
134✔
231
                CadBlockVisibilityParameterTemplate template = new CadBlockVisibilityParameterTemplate(blockVisibilityParameter);
134✔
232

233
                this.readBlock1PtParameter(template);
134✔
234

235
                //281
236
                blockVisibilityParameter.Value281 = this._mergedReaders.ReadBit();
134✔
237
                //301
238
                blockVisibilityParameter.Name = this._mergedReaders.ReadVariableText();
134✔
239
                //302
240
                blockVisibilityParameter.Description = this._mergedReaders.ReadVariableText();
134✔
241
                //missing bit??        91 should be an int
242
                blockVisibilityParameter.Value91 = this._mergedReaders.ReadBit();
134✔
243

244
                //DXF 93 Total entities count
245
                var totalEntitiesCount = this._objectReader.ReadBitLong();
134✔
246
                for (int i = 0; i < totalEntitiesCount; i++)
544✔
247
                {
138✔
248
                        //331
249
                        template.EntityHandles.Add(this.handleReference());
138✔
250
                }
138✔
251

252
                //DXF 92 states count
253
                var nstates = this._objectReader.ReadBitLong();
134✔
254
                for (int j = 0; j < nstates; j++)
1,340✔
255
                {
536✔
256
                        template.StateTemplates.Add(this.readState());
536✔
257
                }
536✔
258

259
                return template;
134✔
260
        }
134✔
261

262
        private void readEvaluationExpression(CadEvaluationExpressionTemplate template)
263
        {
1,075✔
264
                this.readCommonNonEntityData(template);
1,075✔
265

266
                //AcDbEvalExpr
267
                var unknown = this._objectReader.ReadBitLong();
1,075✔
268

269
                //98
270
                template.CadObject.Value98 = this._objectReader.ReadBitLong();
1,075✔
271
                //99
272
                template.CadObject.Value99 = this._objectReader.ReadBitLong();
1,075✔
273

274
                //Code value
275
                short code = this._mergedReaders.ReadBitShort();
1,075✔
276
                if (code > 0)
1,075✔
277
                {
804✔
278
                        var groupValue = GroupCodeValue.TransformValue(code);
804✔
279
                        switch (groupValue)
804!
280
                        {
281
                                case GroupCodeValueType.Double:
282
                                case GroupCodeValueType.ExtendedDataDouble:
283
                                        this._mergedReaders.ReadBitDouble();
804✔
284
                                        break;
804✔
285
                                default:
286
                                        throw new System.NotImplementedException($"[EvaluationExpression] Code not implemented {groupValue}");
×
287
                        }
288
                }
804✔
289

290
                //90
291
                template.CadObject.Id = this._objectReader.ReadBitLong();
1,075✔
292
        }
1,075✔
293

294
        private void readObjectContextData(CadTemplate template)
NEW
295
        {
×
NEW
296
                this.readCommonNonEntityData(template);
×
297

NEW
298
                ObjectContextData contextData = (ObjectContextData)template.CadObject;
×
299

300
                //BS        70        Version (default value is 3).
NEW
301
                contextData.Version = _objectReader.ReadBitShort();
×
302
                //B        290        Default flag (default value is false).
NEW
303
                contextData.Default = _objectReader.ReadBit();
×
NEW
304
        }
×
305

306
        private CadBlockVisibilityParameterTemplate.StateTemplate readState()
307
        {
536✔
308
                CadBlockVisibilityParameterTemplate.StateTemplate template = new CadBlockVisibilityParameterTemplate.StateTemplate();
536✔
309

310
                template.State.Name = this._textReader.ReadVariableText();
536✔
311

312
                //DXF 94 subset count 1
313
                int n1 = this._objectReader.ReadBitLong();
536✔
314
                for (int i = 0; i < n1; i++)
1,894✔
315
                {
411✔
316
                        //332
317
                        template.EntityHandles.Add(this.handleReference());
411✔
318
                }
411✔
319

320
                //DXF 95 subset count 2
321
                var n2 = this._objectReader.ReadBitLong();
536✔
322
                for (int i = 0; i < n2; i++)
4,264✔
323
                {
1,596✔
324
                        //333
325
                        template.ExpressionHandles.Add(this.handleReference());
1,596✔
326
                }
1,596✔
327

328
                return template;
536✔
329
        }
536✔
330
}
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