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

DomCR / ACadSharp / 30620456288

31 Jul 2026 09:34AM UTC coverage: 76.801% (+1.0%) from 75.789%
30620456288

Pull #1151

github

web-flow
Merge 0ffbbdb89 into 25e85fe17
Pull Request #1151: Dynamic parameters

9806 of 13766 branches covered (71.23%)

Branch coverage included in aggregate %.

2995 of 3452 new or added lines in 70 files covered. (86.76%)

74 existing lines in 12 files now uncovered.

34910 of 44457 relevant lines covered (78.53%)

142256.06 hits per line

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

77.09
/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.Objects.cs
1
using ACadSharp.IO.Templates;
2
using ACadSharp.Objects;
3
using ACadSharp.Objects.Evaluations;
4
using System;
5
using System.Collections.Generic;
6

7
namespace ACadSharp.IO.DWG;
8

9
internal partial class DwgObjectReader : DwgSectionIO
10
{
11
        private CadTemplate readAlignmentGrip()
12
        {
2✔
13
                var grip = new BlockAlignmentGrip();
2✔
14
                var template = new CadBlockGripTemplate(grip);
2✔
15

16
                this.readBlockGrip(template);
2✔
17

18
                grip.AlignmentX = this._mergedReaders.ReadBitDouble();
2✔
19
                grip.AlignmentY = this._mergedReaders.ReadBitDouble();
2✔
20
                grip.AlignmentZ = this._mergedReaders.ReadBitDouble();
2✔
21

22
                return template;
2✔
23
        }
2✔
24

25
        private void readAnnotScaleObjectContextData(CadAnnotScaleObjectContextDataTemplate template)
26
        {
×
27
                this.readObjectContextData(template);
×
28

29
                template.ScaleHandle = this.handleReference();
×
30
        }
×
31

32
        private CadTemplate readBlkRefObjectContextData()
33
        {
×
34
                BlockReferenceObjectContextData contextData = new BlockReferenceObjectContextData();
×
35
                CadAnnotScaleObjectContextDataTemplate template = new CadAnnotScaleObjectContextDataTemplate(contextData);
×
36

37
                this.readAnnotScaleObjectContextData(template);
×
38

39
                contextData.Rotation = this._mergedReaders.ReadBitDouble();
×
40
                contextData.InsertionPoint = this._mergedReaders.Read3BitDouble();
×
41
                contextData.XScale = this._mergedReaders.ReadBitDouble();
×
42
                contextData.YScale = this._mergedReaders.ReadBitDouble();
×
43
                contextData.ZScale = this._mergedReaders.ReadBitDouble();
×
44

45
                return template;
×
46
        }
×
47

48
        private void readBlock1PtParameter(CadBlock1PtParameterTemplate template)
49
        {
152✔
50
                this.readBlockParameter(template);
152✔
51

52
                //1010 1020 1030
53
                template.Block1PtParameter.Location = this._mergedReaders.Read3BitDouble();
152✔
54

55
                template.Block1PtParameter.DisplacementX = this.readEvalParameterProperty();
152✔
56
                template.Block1PtParameter.DisplacementY = this.readEvalParameterProperty();
152✔
57

58
                //93
59
                template.Block1PtParameter.GripId = this._mergedReaders.ReadBitLong();
152✔
60
        }
152✔
61

62
        private void readBlock2PtParameter(CadBlock2PtParameterTemplate template)
63
        {
160✔
64
                this.readBlockParameter(template);
160✔
65

66
                //1010 1020 1030
67
                template.Block2PtParameter.FirstPoint = this._mergedReaders.Read3BitDouble();
160✔
68
                //1011 1021 1031
69
                template.Block2PtParameter.SecondPoint = this._mergedReaders.Read3BitDouble();
160✔
70

71
                template.Block2PtParameter.FirstPointDisplacementX = this.readEvalParameterProperty();
160✔
72
                template.Block2PtParameter.FirstPointDisplacementY = this.readEvalParameterProperty();
160✔
73
                template.Block2PtParameter.SecondPointDisplacementX = this.readEvalParameterProperty();
160✔
74
                template.Block2PtParameter.SecondPointDisplacementY = this.readEvalParameterProperty();
160✔
75

76
                //91 values
77
                template.Block2PtParameter.GripIds.Add(this._mergedReaders.ReadBitLong());
160✔
78
                template.Block2PtParameter.GripIds.Add(this._mergedReaders.ReadBitLong());
160✔
79
                template.Block2PtParameter.GripIds.Add(this._mergedReaders.ReadBitLong());
160✔
80
                template.Block2PtParameter.GripIds.Add(this._mergedReaders.ReadBitLong());
160✔
81

82
                //177
83
                template.Block2PtParameter.BaseLocation = (LinearParameterBaseLocation)this._mergedReaders.ReadBitShort();
160✔
84
        }
160✔
85

86
        private void readBlockAction(CadBlockActionTemplate template)
87
        {
164✔
88
                this.readBlockElement(template);
164✔
89

90
                BlockAction blockAction = template.BlockAction;
164✔
91

92
                // 1010, 1020, 1030
93
                blockAction.LabelPosition = this._mergedReaders.Read3BitDouble();
164✔
94

95
                //71
96
                int entityCount = this._objectReader.ReadBitLong();
164✔
97
                for (int i = 0; i < entityCount; i++)
668✔
98
                {
170✔
99
                        ulong entityHandle = this.handleReference();
170✔
100
                        template.EntityHandles.Add(entityHandle);
170✔
101
                }
170✔
102

103
                // 70
104
                int nparameters = this._mergedReaders.ReadBitLong();
164✔
105
                for (int i = 0; i < nparameters; i++)
328!
106
                {
×
NEW
107
                        blockAction.ParametersIds.Add(this._mergedReaders.ReadBitLong());
×
108
                }
×
109
        }
164✔
110

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

115
                BlockActionBasePt blockActionBasePt = template.CadObject as BlockActionBasePt;
144✔
116

117
                blockActionBasePt.BasePoint = this._mergedReaders.Read3BitDouble();
144✔
118

119
                blockActionBasePt.UpdateBaseXConnection = this.readEvalConnection();
144✔
120
                blockActionBasePt.UpdateBaseYConnection = this.readEvalConnection();
144✔
121

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

126
        private CadTemplate readBlockAlignmentParameter()
127
        {
2✔
128
                BlockAlignmentParameter parameter = new();
2✔
129
                CadBlock2PtParameterTemplate template = new(parameter);
2✔
130

131
                this.readBlock2PtParameter(template);
2✔
132

133
                parameter.IsPerpendicular = this._mergedReaders.ReadBit();
2✔
134

135
                return template;
2✔
136
        }
2✔
137

138
        private CadTemplate readBlockArrayAction()
139
        {
2✔
140
                var array = new BlockArrayAction();
2✔
141
                CadBlockActionTemplate template = new CadBlockActionTemplate(array);
2✔
142

143
                this.readBlockAction(template);
2✔
144

145
                array.BaseConnection = this.readEvalConnection();
2✔
146
                array.EndConnection = this.readEvalConnection();
2✔
147
                array.UpdatedBaseConnection = this.readEvalConnection();
2✔
148
                array.UpdatedEndConnection = this.readEvalConnection();
2✔
149

150
                array.RowOffset = this._mergedReaders.ReadBitDouble();
2✔
151
                array.ColumnOffset = this._mergedReaders.ReadBitDouble();
2✔
152

153
                return template;
2✔
154
        }
2✔
155

156
        private CadTemplate readBlockBasePointParameter()
157
        {
2✔
158
                BlockBasePointParameter parameter = new();
2✔
159
                CadBlock1PtParameterTemplate template = new(parameter);
2✔
160

161
                this.readBlock1PtParameter(template);
2✔
162

163
                parameter.Point1011 = this._mergedReaders.Read3BitDouble();
2✔
164
                parameter.Point1012 = this._mergedReaders.Read3BitDouble();
2✔
165

166
                return template;
2✔
167
        }
2✔
168

169
        private void readBlockElement(CadBlockElementTemplate template)
170
        {
942✔
171
                this.readEvaluationExpression(template);
942✔
172

173
                //300 name
174
                template.BlockElement.ElementName = this._mergedReaders.ReadVariableText();
942✔
175
                //98
176
                template.BlockElement.Value98 = this._mergedReaders.ReadBitLong();
942✔
177
                //99
178
                template.BlockElement.Value99 = this._mergedReaders.ReadBitLong();
942✔
179
                //1071
180
                template.BlockElement.Value1071 = this._mergedReaders.ReadBitLong();
942✔
181
        }
942✔
182

183
        private CadTemplate readBlockFlipAction()
184
        {
2✔
185
                BlockFlipAction flipAction = new BlockFlipAction();
2✔
186
                CadBlockFlipActionTemplate template = new CadBlockFlipActionTemplate(flipAction);
2✔
187

188
                this.readBlockAction(template);
2✔
189

190
                flipAction.FlipConnection = this.readEvalConnection();
2✔
191
                flipAction.UpdatedFlipConnection = this.readEvalConnection();
2✔
192
                flipAction.UpdatedBaseConnection = this.readEvalConnection();
2✔
193
                flipAction.UpdatedEndConnection = this.readEvalConnection();
2✔
194

195
                return template;
2✔
196
        }
2✔
197

198
        private CadBlockFlipParameterTemplate readBlockFlipParameter()
199
        {
2✔
200
                BlockFlipParameter flip = new BlockFlipParameter();
2✔
201
                CadBlockFlipParameterTemplate template = new CadBlockFlipParameterTemplate(flip);
2✔
202

203
                this.readBlock2PtParameter(template);
2✔
204

205
                flip.Label = this._mergedReaders.ReadVariableText();
2✔
206
                flip.Description = this._mergedReaders.ReadVariableText();
2✔
207
                flip.BaseStateName = this._mergedReaders.ReadVariableText();
2✔
208
                flip.FlippedStateName = this._mergedReaders.ReadVariableText();
2✔
209

210
                flip.LabelPosition = this._mergedReaders.Read3BitDouble();
2✔
211

212
                flip.UpdatedFlipConnection = this.readEvalConnection();
2✔
213

214
                return template;
2✔
215
        }
2✔
216

217
        private void readBlockGrip(CadBlockGripTemplate template)
218
        {
466✔
219
                this.readBlockElement(template);
466✔
220

221
                var blockGrip = template.CadObject as BlockGrip;
466✔
222

223
                blockGrip.ExpressionId1 = this._mergedReaders.ReadBitLong();
466✔
224
                blockGrip.ExpressionId2 = this._mergedReaders.ReadBitLong();
466✔
225

226
                blockGrip.Location = this._mergedReaders.Read3BitDouble();
466✔
227
                blockGrip.Cycling = this._mergedReaders.ReadBit();
466✔
228

229
                blockGrip.Value93 = this._mergedReaders.ReadBitLong();
466✔
230
        }
466✔
231

232
        private CadTemplate readBlockGripLocationComponent()
233
        {
934✔
234
                BlockGripLocationComponent grip = new BlockGripLocationComponent();
934✔
235
                CadBlockGripLocationComponentTemplate template = new CadBlockGripLocationComponentTemplate(grip);
934✔
236

237
                this.readEvaluationExpression(template);
934✔
238

239
                grip.Connection = this.readEvalConnection();
934✔
240

241
                return template;
934✔
242
        }
934✔
243

244
        private CadTemplate readBlockLinearParameter()
245
        {
144✔
246
                BlockLinearParameter blockLinearParameter = new();
144✔
247
                CadBlockLinearParameterTemplate template = new CadBlockLinearParameterTemplate(blockLinearParameter);
144✔
248

249
                this.readBlock2PtParameter(template);
144✔
250

251
                //305
252
                blockLinearParameter.Label = this._mergedReaders.ReadVariableText();
144✔
253
                //306
254
                blockLinearParameter.Description = this._mergedReaders.ReadVariableText();
144✔
255
                //140
256
                blockLinearParameter.LabelOffset = this._mergedReaders.ReadBitDouble();
144✔
257

258
                blockLinearParameter.ValueSet = this.readParameterValueSet();
144✔
259

260
                return template;
144✔
261
        }
144✔
262

263
        private CadTemplate readBlockLookupAction()
264
        {
2✔
265
                var lookupAction = new BlockLookupAction();
2✔
266
                CadBlockLookupActionTemplate template = new CadBlockLookupActionTemplate(lookupAction);
2✔
267

268
                this.readBlockAction(template);
2✔
269

270
                template.NumberOfRows = this._mergedReaders.ReadBitLong();
2✔
271
                template.NumberOfColumns = this._mergedReaders.ReadBitLong();
2✔
272

273
                for (int i = 0; i < template.NumberOfRows * template.NumberOfColumns; i++)
64!
274
                {
30✔
275
                        template.RowValues.Add(this._mergedReaders.ReadVariableText());
30✔
276
                }
30✔
277

278
                for (int j = 0; j < template.NumberOfColumns; j++)
24✔
279
                {
10✔
280
                        lookupAction.Columns.Add(this.readLookupActionColumn());
10✔
281
                }
10✔
282

283
                lookupAction.UnknownFlag = this._mergedReaders.ReadBit();
2✔
284

285
                return template;
2✔
286
        }
2✔
287

288
        private CadTemplate readBlockLookupParameter()
289
        {
4✔
290
                BlockLookupParameter blockLookupParameter = new BlockLookupParameter();
4✔
291
                CadBlockLookupParameterTemplate template = new CadBlockLookupParameterTemplate(blockLookupParameter);
4✔
292

293
                this.readBlock1PtParameter(template);
4✔
294

295
                blockLookupParameter.ActionId = this._mergedReaders.ReadBitLong();
4✔
296
                blockLookupParameter.Label = this._mergedReaders.ReadVariableText();
4✔
297
                blockLookupParameter.Description = this._mergedReaders.ReadVariableText();
4✔
298

299
                return template;
4✔
300
        }
4✔
301

302
        private CadTemplate readBlockMoveAction()
303
        {
4✔
304
                BlockMoveAction blockMoveAction = new();
4✔
305
                CadBlockMoveActionTemplate template = new CadBlockMoveActionTemplate(blockMoveAction);
4✔
306

307
                this.readBlockAction(template);
4✔
308

309
                blockMoveAction.XDeltaConnection = this.readEvalConnection();
4✔
310
                blockMoveAction.YDeltaConnection = this.readEvalConnection();
4✔
311

312
                blockMoveAction.DistanceMultiplier = this._mergedReaders.ReadBitDouble();
4✔
313
                blockMoveAction.AngleOffset = this._mergedReaders.ReadBitDouble();
4✔
314
                blockMoveAction.UnknownFlag = this._mergedReaders.ReadByte();
4✔
315

316
                return template;
4✔
317
        }
4✔
318

319
        private void readBlockParameter(CadBlockParameterTemplate template)
320
        {
312✔
321
                this.readBlockElement(template);
312✔
322

323
                //280
324
                template.BlockParameter.ShowProperties = this._mergedReaders.ReadBit();
312✔
325
                //281
326
                template.BlockParameter.ChainActions = this._mergedReaders.ReadBit();
312✔
327
        }
312✔
328

329
        private CadTemplate readBlockPointParameter()
330
        {
4✔
331
                BlockPointParameter blockPointParameter = new();
4✔
332
                CadBlockPointParameterTemplate template = new(blockPointParameter);
4✔
333

334
                this.readBlock1PtParameter(template);
4✔
335

336
                blockPointParameter.Label = this._mergedReaders.ReadVariableText();
4✔
337
                blockPointParameter.Description = this._mergedReaders.ReadVariableText();
4✔
338
                blockPointParameter.LabelPosition = this._mergedReaders.Read3BitDouble();
4✔
339

340
                return template;
4✔
341
        }
4✔
342

343
        private CadTemplate readBlockPolarParameter()
344
        {
8✔
345
                BlockPolarParameter polar = new();
8✔
346
                CadBlock2PtParameterTemplate template = new CadBlock2PtParameterTemplate(polar);
8✔
347

348
                this.readBlock2PtParameter(template);
8✔
349

350
                polar.Label = this._mergedReaders.ReadVariableText();
8✔
351
                polar.Description = this._mergedReaders.ReadVariableText();
8✔
352
                polar.AngleName = this._mergedReaders.ReadVariableText();
8✔
353
                polar.AngleDescription = this._mergedReaders.ReadVariableText();
8✔
354

355
                polar.LabelOffset = this._mergedReaders.ReadBitDouble();
8✔
356

357
                polar.DistanceValueSet = this.readParameterValueSet();
8✔
358
                polar.AngleValueSet = this.readParameterValueSet();
8✔
359

360
                return template;
8✔
361
        }
8✔
362

363
        private CadTemplate readBlockPolarStretchAction()
364
        {
8✔
365
                BlockPolarStretchAction stretchAction = new BlockPolarStretchAction();
8✔
366
                CadPolarStretchActionTemplate template = new CadPolarStretchActionTemplate(stretchAction);
8✔
367

368
                this.readBlockAction(template);
8✔
369

370
                stretchAction.BaseXDeltaConnection = this.readEvalConnection();
8✔
371
                stretchAction.BaseYDeltaConnection = this.readEvalConnection();
8✔
372
                stretchAction.BaseConnection = this.readEvalConnection();
8✔
373
                stretchAction.EndConnection = this.readEvalConnection();
8✔
374
                stretchAction.UpdatedBaseConnection = this.readEvalConnection();
8✔
375
                stretchAction.UpdatedEndConnection = this.readEvalConnection();
8✔
376

377
                int npts = this._mergedReaders.ReadBitLong();
8✔
378
                for (int i = 0; i < npts; i++)
48✔
379
                {
16✔
380
                        stretchAction.Boundary.Add(this._mergedReaders.Read2RawDouble());
16✔
381
                }
16✔
382

383
                var selection = this._mergedReaders.ReadBitLong();
8✔
384
                for (int j = 0; j < selection; j++)
24✔
385
                {
4✔
386
                        template.SelectionHandles.Add(this.handleReference());
4✔
387
                }
4✔
388

389
                int nbindings = this._mergedReaders.ReadBitLong();
8✔
390
                for (int i = 0; i < nbindings; i++)
32✔
391
                {
8✔
392
                        var h = this.handleReference();
8✔
393

394
                        StretchEntityBind bind = new StretchEntityBind();
8✔
395
                        int nindexes = this._mergedReaders.ReadBitLong();
8✔
396
                        for (int j = 0; j < nindexes; j++)
32✔
397
                        {
8✔
398
                                bind.PointIndexes.Add(this._mergedReaders.ReadBitLong());
8✔
399
                        }
8✔
400

401
                        template.Bindings.Add(h, bind);
8✔
402
                }
8✔
403

404
                int nnodes = this._mergedReaders.ReadBitLong();
8✔
405
                for (int i = 0; i < nnodes; i++)
16!
NEW
406
                {
×
NEW
407
                        var nodeId = this._mergedReaders.ReadBitLong();
×
NEW
408
                        int nindexes = this._mergedReaders.ReadBitLong();
×
NEW
409
                        List<int> indexes = new List<int>();
×
NEW
410
                        for (int j = 0; j < nindexes; j++)
×
NEW
411
                        {
×
NEW
412
                                indexes.Add(this._mergedReaders.ReadBitLong());
×
NEW
413
                        }
×
414

NEW
415
                        stretchAction.StretchNodes.Add(new StretchNode(nodeId, indexes));
×
NEW
416
                }
×
417

418
                stretchAction.DistanceMultiplier = this._mergedReaders.ReadBitDouble();
8✔
419
                stretchAction.AngleOffset = this._mergedReaders.ReadBitDouble();
8✔
420

421
                var unknown = this._mergedReaders.ReadBitLong();
8✔
422
                for (int i = 0; i < unknown; i++)
16!
NEW
423
                {
×
NEW
424
                        var tmp = this._mergedReaders.ReadBitLong();
×
NEW
425
                }
×
426

427
                return template;
8✔
428
        }
8✔
429

430
        private CadTemplate readBlockRepresentationData()
431
        {
320✔
432
                BlockRepresentationData representation = new BlockRepresentationData();
320✔
433
                CadBlockRepresentationDataTemplate template = new CadBlockRepresentationDataTemplate(representation);
320✔
434

435
                this.readCommonNonEntityData(template);
320✔
436

437
                representation.Version = this._mergedReaders.ReadBitShort();
320✔
438
                template.BlockHandle = this.handleReference();
320✔
439

440
                return template;
320✔
441
        }
320✔
442

443
        private CadTemplate readBlockRotateAction()
444
        {
2✔
445
                BlockRotationAction rotationAction = new();
2✔
446
                CadBlockRotationActionTemplate template = new(rotationAction);
2✔
447

448
                this.readBlockActionBasePt(template);
2✔
449

450
                rotationAction.AngleDeltaConnection = this.readEvalConnection();
2✔
451

452
                return template;
2✔
453
        }
2✔
454

455
        private CadTemplate readBlockRotationParameter()
456
        {
2✔
457
                BlockRotationParameter blockRotationParameter = new();
2✔
458
                CadBlockRotationParameterTemplate template = new CadBlockRotationParameterTemplate(blockRotationParameter);
2✔
459

460
                this.readBlock2PtParameter(template);
2✔
461

462
                //1011 1021 1031
463
                blockRotationParameter.Point = this._mergedReaders.Read3BitDouble();
2✔
464
                //305
465
                blockRotationParameter.Label = this._mergedReaders.ReadVariableText();
2✔
466
                //306
467
                blockRotationParameter.Description = this._mergedReaders.ReadVariableText();
2✔
468
                //140
469
                blockRotationParameter.LabelOffset = this._mergedReaders.ReadBitDouble();
2✔
470

471
                blockRotationParameter.ValueSet = this.readParameterValueSet();
2✔
472

473
                return template;
2✔
474
        }
2✔
475

476
        private CadTemplate readBlockScaleAction()
477
        {
142✔
478
                BlockScaleAction scaleAction = new();
142✔
479
                CadBlockScaleActionTemplate template = new(scaleAction);
142✔
480

481
                this.readBlockActionBasePt(template);
142✔
482

483
                scaleAction.ScaleConnection = this.readEvalConnection();
142✔
484
                scaleAction.XScaleConnection = this.readEvalConnection();
142✔
485
                scaleAction.YScaleConnection = this.readEvalConnection();
142✔
486

487
                scaleAction.ScaleType = this._mergedReaders.ReadByte();
142✔
488

489
                return template;
142✔
490
        }
142✔
491

492
        private CadTemplate readBlockStretchAction()
493
        {
2✔
494
                BlockStretchAction stretchAction = new();
2✔
495
                CadStretchActionBaseTemplate template = new CadStretchActionBaseTemplate(stretchAction);
2✔
496

497
                this.readBlockAction(template);
2✔
498

499
                stretchAction.EndXDeltaConnection = this.readEvalConnection();
2✔
500
                stretchAction.EndYDeltaConnection = this.readEvalConnection();
2✔
501

502
                int npts = this._mergedReaders.ReadBitLong();
2✔
503
                for (int i = 0; i < npts; i++)
12✔
504
                {
4✔
505
                        stretchAction.Boundary.Add(this._mergedReaders.Read2RawDouble());
4✔
506
                }
4✔
507

508
                int nbindings = this._mergedReaders.ReadBitLong();
2✔
509
                for (int i = 0; i < nbindings; i++)
8✔
510
                {
2✔
511
                        var h = this.handleReference();
2✔
512

513
                        StretchEntityBind bind = new StretchEntityBind();
2✔
514
                        int nindexes = this._mergedReaders.ReadBitLong();
2✔
515
                        for (int j = 0; j < nindexes; j++)
12✔
516
                        {
4✔
517
                                bind.PointIndexes.Add(this._mergedReaders.ReadBitLong());
4✔
518
                        }
4✔
519

520
                        template.Bindings.Add(h, bind);
2✔
521
                }
2✔
522

523
                int nnodes = this._mergedReaders.ReadBitLong();
2✔
524
                for (int i = 0; i < nnodes; i++)
4!
NEW
525
                {
×
NEW
526
                        var nodeId = this._mergedReaders.ReadBitLong();
×
NEW
527
                        int nindexes = this._mergedReaders.ReadBitLong();
×
NEW
528
                        List<int> indexes = new List<int>();
×
NEW
529
                        for (int j = 0; j < nindexes; j++)
×
NEW
530
                        {
×
NEW
531
                                indexes.Add(this._mergedReaders.ReadBitLong());
×
NEW
532
                        }
×
533

NEW
534
                        stretchAction.StretchNodes.Add(new StretchNode(nodeId, indexes));
×
NEW
535
                }
×
536

537
                stretchAction.DistanceMultiplier = this._mergedReaders.ReadBitDouble();
2✔
538
                stretchAction.AngleOffset = this._mergedReaders.ReadBitDouble();
2✔
539
                stretchAction.UnknownFlag = this._mergedReaders.ReadByte();
2✔
540

541
                return template;
2✔
542
        }
2✔
543

544
        private CadTemplate readBlockVisibilityParameter()
545
        {
142✔
546
                BlockVisibilityParameter blockVisibilityParameter = new BlockVisibilityParameter();
142✔
547
                CadBlockVisibilityParameterTemplate template = new CadBlockVisibilityParameterTemplate(blockVisibilityParameter);
142✔
548

549
                this.readBlock1PtParameter(template);
142✔
550

551
                //281
552
                blockVisibilityParameter.ChainActions = this._mergedReaders.ReadBit();
142✔
553
                //301
554
                blockVisibilityParameter.Label = this._mergedReaders.ReadVariableText();
142✔
555
                //302
556
                blockVisibilityParameter.Description = this._mergedReaders.ReadVariableText();
142✔
557
                //missing bit??        91 should be an int
558
                blockVisibilityParameter.Value91 = this._mergedReaders.ReadBit();
142✔
559

560
                //DXF 93 Total entities count
561
                var totalEntitiesCount = this._objectReader.ReadBitLong();
142✔
562
                for (int i = 0; i < totalEntitiesCount; i++)
584✔
563
                {
150✔
564
                        //331
565
                        template.EntityHandles.Add(this.handleReference());
150✔
566
                }
150✔
567

568
                //DXF 92 states count
569
                var nstates = this._objectReader.ReadBitLong();
142✔
570
                for (int j = 0; j < nstates; j++)
1,420✔
571
                {
568✔
572
                        template.StateTemplates.Add(this.readState());
568✔
573
                }
568✔
574

575
                return template;
142✔
576
        }
142✔
577

578
        private CadTemplate readBlockXYParameter()
579
        {
2✔
580
                BlockXYParameter parameter = new();
2✔
581
                CadBlock2PtParameterTemplate template = new CadBlock2PtParameterTemplate(parameter);
2✔
582

583
                this.readBlock2PtParameter(template);
2✔
584

585
                parameter.LabelY = this._mergedReaders.ReadVariableText();
2✔
586
                parameter.LabelX = this._mergedReaders.ReadVariableText();
2✔
587
                parameter.DescriptionY = this._mergedReaders.ReadVariableText();
2✔
588
                parameter.DescriptionX = this._mergedReaders.ReadVariableText();
2✔
589

590
                parameter.LabelOffsetX = this._mergedReaders.ReadBitDouble();
2✔
591
                parameter.LabelOffsetY = this._mergedReaders.ReadBitDouble();
2✔
592

593
                parameter.ValueSetX = this.readParameterValueSet();
2✔
594
                parameter.ValueSetY = this.readParameterValueSet();
2✔
595

596
                return template;
2✔
597
        }
2✔
598

599
        private CadValueTemplate readCadValue(CadValue value)
600
        {
5,200✔
601
                CadValueTemplate template = new CadValueTemplate(value);
5,200✔
602

603
                //R2007+:
604
                if (this.R2007Plus)
5,200✔
605
                {
5,200✔
606
                        //Flags BL 93 Flags & 0x01 => type is kGeneral
607
                        value.Flags = this._mergedReaders.ReadBitLong();
5,200✔
608
                }
5,200✔
609

610
                //Common:
611
                //Data type BL 90
612
                value.ValueType = (CadValueType)this._mergedReaders.ReadBitLong();
5,200✔
613
                if (!this.R2007Plus || !value.IsEmpty)
5,200!
614
                {
3,920✔
615
                        //Varies by type: Not present in case bit 1 in Flags is set
616
                        switch (value.ValueType)
3,920!
617
                        {
618
                                case CadValueType.Unknown:
619
                                case CadValueType.Long:
620
                                        value.SetValue(this._mergedReaders.ReadBitLong());
80✔
621
                                        break;
80✔
622
                                case CadValueType.Double:
623
                                        value.SetValue(this._mergedReaders.ReadBitDouble());
2,720✔
624
                                        break;
2,720✔
625
                                case CadValueType.General:
626
                                case CadValueType.String:
627
                                        value.SetValue(this.readStringCadValue());
960✔
628
                                        break;
960✔
629
                                case CadValueType.Date:
630
                                        System.DateTime? dateTime = this.readDateCadValue();
80✔
631
                                        if (dateTime.HasValue)
80✔
632
                                        {
80✔
633
                                                value.SetValue(dateTime.Value);
80✔
634
                                        }
80✔
635
                                        break;
80✔
636
                                case CadValueType.Point2D:
637
                                        value.SetValue(this.readValueXY());
×
638
                                        break;
×
639
                                case CadValueType.Point3D:
640
                                        value.SetValue(this.readValueXYZ());
80✔
641
                                        break;
80✔
642
                                case CadValueType.Handle:
643
                                        template.ValueHandle = this.handleReference();
×
644
                                        break;
×
645
                                case CadValueType.Buffer:
646
                                case CadValueType.ResultBuffer:
647
                                default:
648
                                        throw new NotImplementedException();
×
649
                        }
650
                }
3,920✔
651

652
                //R2007+:
653
                if (this.R2007Plus)
5,200✔
654
                {
5,200✔
655
                        //Unit type BL 94 0 = no units, 1 = distance, 2 = angle, 4 = area, 8 = volume
656
                        value.Units = (CadValueUnitType)this._mergedReaders.ReadBitLong();
5,200✔
657
                        //Format String TV 300
658
                        value.Format = this._mergedReaders.ReadVariableText();
5,200✔
659
                        //Value String TV 302
660
                        value.FormattedValue = this._mergedReaders.ReadVariableText();
5,200✔
661
                }
5,200✔
662

663
                return template;
5,200✔
664
        }
5,200✔
665

666
        private CadTemplate readDynamicBlockPurgePreventer()
667
        {
160✔
668
                var purgePreventer = new DynamicBlockPurgePreventer();
160✔
669
                var template = new DynamicBlockPurgePreventerTemplate(purgePreventer);
160✔
670

671
                this.readCommonNonEntityData(template);
160✔
672

673
                purgePreventer.Version = this._mergedReaders.ReadBitShort();
160✔
674

675
                template.BlockHandle = this.handleReference();
160✔
676

677
                return template;
160✔
678
        }
160✔
679

680
        private EvalConnection readEvalConnection()
681
        {
2,360✔
682
                EvalConnection connection = new EvalConnection();
2,360✔
683

684
                //94 95 (I guess 96 97)
685
                connection.Id = this._mergedReaders.ReadBitLong();
2,360✔
686
                //303 304 : exposed custom property label
687
                connection.Name = this._mergedReaders.ReadVariableText();
2,360✔
688

689
                return connection;
2,360✔
690
        }
2,360✔
691

692
        private EvalParameterProperty readEvalParameterProperty()
693
        {
944✔
694
                EvalParameterProperty eprop = new EvalParameterProperty();
944✔
695

696
                //170 171
697
                short n = this._mergedReaders.ReadBitShort();
944✔
698
                for (int j = 0; j < n; j++)
3,152✔
699
                {
632✔
700
                        eprop.Connections.Add(this.readEvalConnection());
632✔
701
                }
632✔
702

703
                return eprop;
944✔
704
        }
944✔
705

706
        private void readEvaluationExpression(CadEvaluationExpressionTemplate template)
707
        {
1,876✔
708
                this.readCommonNonEntityData(template);
1,876✔
709

710
                //AcDbEvalExpr
711
                template.CadObject.Unknown = this._objectReader.ReadBitLong();
1,876✔
712

713
                //98
714
                template.CadObject.Value98 = this._objectReader.ReadBitLong();
1,876✔
715
                //99
716
                template.CadObject.Value99 = this._objectReader.ReadBitLong();
1,876✔
717

718
                //Code value
719
                short code = this._mergedReaders.ReadBitShort();
1,876✔
720
                if (code > 0)
1,876✔
721
                {
934✔
722
                        var groupValue = GroupCodeValue.TransformValue(code);
934✔
723
                        object value = null;
934✔
724
                        switch (groupValue)
934!
725
                        {
726
                                case GroupCodeValueType.String:
727
                                case GroupCodeValueType.ExtendedDataString:
NEW
728
                                        value = this._mergedReaders.ReadVariableText();
×
NEW
729
                                        break;
×
730
                                case GroupCodeValueType.Int16:
731
                                case GroupCodeValueType.ExtendedDataInt16:
732
                                        value = this._mergedReaders.ReadBitShort();
2✔
733
                                        break;
2✔
734
                                case GroupCodeValueType.Double:
735
                                case GroupCodeValueType.ExtendedDataDouble:
736
                                        value = this._mergedReaders.ReadBitDouble();
932✔
737
                                        break;
932✔
738
                                case GroupCodeValueType.Int32:
739
                                case GroupCodeValueType.Int64:
740
                                case GroupCodeValueType.ExtendedDataInt32:
NEW
741
                                        value = this._mergedReaders.ReadBitLong();
×
NEW
742
                                        break;
×
743
                                case GroupCodeValueType.Point3D:
NEW
744
                                        value = this._mergedReaders.Read3BitDouble();
×
UNCOV
745
                                        break;
×
746
                                default:
747
                                        throw new System.NotImplementedException($"[EvaluationExpression] Code not implemented {groupValue}");
×
748
                        }
749

750
                        template.CadObject.EvaluatedValue = new DxfValuePair((DxfCode)code, value);
934✔
751
                }
934✔
752

753
                //90
754
                template.CadObject.Id = this._objectReader.ReadBitLong();
1,876✔
755
        }
1,876✔
756

757
        private CadTemplate readEvaluationGraph()
758
        {
162✔
759
                EvaluationGraph evaluationGraph = new EvaluationGraph();
162✔
760
                CadEvaluationGraphTemplate template = new CadEvaluationGraphTemplate(evaluationGraph);
162✔
761

762
                this.readCommonNonEntityData(template);
162✔
763

764
                //DXF fields 96, 97 contain the value 5, here are three fields returning the same value 5
765
                evaluationGraph.Value96 = this._objectReader.ReadBitLong();
162✔
766
                evaluationGraph.Value97 = this._objectReader.ReadBitLong();
162✔
767

768
                int nodeCount = this._objectReader.ReadBitLong();
162✔
769
                for (int i = 0; i < nodeCount; i++)
4,076✔
770
                {
1,876✔
771
                        var node = evaluationGraph.CreateNode();
1,876✔
772
                        var nodeTemplate = new CadEvaluationGraphTemplate.GraphNodeTemplate(node);
1,876✔
773
                        template.NodeTemplates.Add(nodeTemplate);
1,876✔
774

775
                        //Code 91
776
                        node.Index = this._objectReader.ReadBitLong();
1,876✔
777
                        //Code 93
778
                        node.Flags = (EvaluationGraph.NodeFlags)this._objectReader.ReadBitLong();
1,876✔
779

780
                        //Code 95
781
                        node.Id = this._objectReader.ReadBitLong();
1,876✔
782

783
                        //Code 360
784
                        nodeTemplate.ExpressionHandle = this.handleReference();
1,876✔
785

786
                        //Codes 92, x4
787
                        node.Data1 = this._objectReader.ReadBitLong();
1,876✔
788
                        node.Data2 = this._objectReader.ReadBitLong();
1,876✔
789
                        node.Data3 = this._objectReader.ReadBitLong();
1,876✔
790
                        node.Data4 = this._objectReader.ReadBitLong();
1,876✔
791
                }
1,876✔
792

793
                //Last node has x5 92 with the last value as 0 instead of x4
794
                //Followed by a 93
795
                var edgeCount = this._objectReader.ReadBitLong();
162✔
796
                for (int i = 0; i < edgeCount; i++)
3,480✔
797
                {
1,578✔
798
                        var edge = new EvaluationGraph.Edge();
1,578✔
799

800
                        //id BL, DXF 92
801
                        //nextid BLd, DXF 93
802
                        //e1 BLd, DXF 94
803
                        //e2 BLd, DXF 91
804
                        //e3 BLd, DXF 91
805
                        //out_edge BLd
806

807
                        //92 index
808
                        edge.Index = this._objectReader.ReadBitLong();
1,578✔
809
                        //93
810
                        edge.Flags = this._objectReader.ReadBitLong();
1,578✔
811
                        //94
812
                        edge.TrackedCount = this._objectReader.ReadBitLong();
1,578✔
813

814
                        //91
815
                        edge.FromNodeIndex = this._objectReader.ReadBitLong();
1,578✔
816
                        //91
817
                        edge.ToNodeIndex = this._objectReader.ReadBitLong();
1,578✔
818

819
                        //92 x5
820
                        edge.Data1 = this._objectReader.ReadBitLong();
1,578✔
821
                        edge.Data2 = this._objectReader.ReadBitLong();
1,578✔
822
                        edge.Data3 = this._objectReader.ReadBitLong();
1,578✔
823
                        edge.Data4 = this._objectReader.ReadBitLong();
1,578✔
824
                        edge.Data5 = this._objectReader.ReadBitLong();
1,578✔
825

826
                        evaluationGraph.Edges.Add(edge);
1,578✔
827
                }
1,578✔
828

829
                return template;
162✔
830
        }
162✔
831

832
        private CadTemplate readField()
833
        {
×
834
                var field = new Field();
×
835
                CadFieldTemplate template = new CadFieldTemplate(field);
×
836

837
                this.readCommonNonEntityData(template);
×
838

839
                //TV 1 Evaluator ID TV 2,3 Field code(in DXF strings longer than 255 characters
840
                //are written in chunks of 255 characters in one 2 group and one or
841
                //more 3 groups).
842
                field.EvaluatorId = this._mergedReaders.ReadVariableText();
×
843
                field.FieldCode = this._mergedReaders.ReadVariableText();
×
844
                //BL 90 Number of child fields
845
                int nchild = this._mergedReaders.ReadBitLong();
×
846
                for (int i = 0; i < nchild; i++)
×
847
                {
×
848
                        //H 360 Child field handle (hard owner)
849
                        template.ChildrenHandles.Add(this.handleReference());
×
850
                }
×
851

852
                //BL 97 Number of field objects
853
                int nfields = this._mergedReaders.ReadBitLong();
×
854
                for (int j = 0; j < nfields; j++)
×
855
                {
×
856
                        //H 331 Field object handle (soft pointer)
857
                        template.CadObjectsHandles.Add(this.handleReference());
×
858
                }
×
859

860
                //-R2004
861
                if (this._version < ACadVersion.AC1021)
×
862
                {
×
863
                        //TV 4 Format string. After R2004 the format became part of the value object.
864
                        field.FormatString = this._mergedReaders.ReadVariableText();
×
865
                }
×
866

867
                //Common BL 91 Evaluation option flags:
868
                field.EvaluationOptionFlags = (EvaluationOptionFlags)this._mergedReaders.ReadBitLong();
×
869
                //BL 92 Filing option flags:
870
                field.FilingOptionFlags = (FilingOptionFlags)this._mergedReaders.ReadBitLong();
×
871
                //BL 96 Evaluation error code
872
                field.FieldStateFlags = (FieldStateFlags)this._mergedReaders.ReadBitLong();
×
873
                //BL 94 Field state flags:
874
                field.EvaluationStatusFlags = (EvaluationStatusFlags)this._mergedReaders.ReadBitLong();
×
875
                //BL 96 Evaluation error code
876
                field.EvaluationErrorCode = this._mergedReaders.ReadBitLong();
×
877
                //TV 300 Evaluation error message
878
                field.EvaluationErrorMessage = this._mergedReaders.ReadVariableText();
×
879

880
                //... ... The field value, see paragraph 20.4.99.
881
                template.CadValueTemplates.Add(this.readCadValue(field.Value));
×
882

883
                //TV 301,9 Value string(DXF: written in 255 character chunks)
884
                field.FormatString = this._mergedReaders.ReadVariableText();
×
885
                this._mergedReaders.ReadBitLong();
×
886
                int num3 = this._mergedReaders.ReadBitLong();
×
887
                for (int k = 0; k < num3; k++)
×
888
                {
×
889
                        //TV 6 Child field key
890
                        string key = this._mergedReaders.ReadVariableText();
×
891
                        CadValue value = new CadValue();
×
892
                        template.CadValueTemplates.Add(this.readCadValue(value));
×
893
                        field.Values.Add(key, value);
×
894
                }
×
895

896
                return template;
×
897
        }
×
898

899
        private CadTemplate readFieldList()
900
        {
×
901
                FieldList fieldList = new FieldList();
×
902
                CadFieldListTemplate template = new CadFieldListTemplate(fieldList);
×
903

904
                this.readCommonNonEntityData(template);
×
905

906
                //BL Number of fields
907
                int nhandles = this._mergedReaders.ReadBitLong();
×
908
                //B Unknown
909
                this._mergedReaders.ReadBit();
×
910
                for (int i = 0; i < nhandles; i++)
×
911
                {
×
912
                        //H 330 Field handle (soft pointer)
913
                        template.OwnedObjectsHandlers.Add(this.handleReference());
×
914
                }
×
915

916
                return template;
×
917
        }
×
918

919
        private CadTemplate readFlipGrip()
920
        {
2✔
921
                var grip = new BlockFlipGrip();
2✔
922
                var template = new CadBlockGripTemplate(grip);
2✔
923

924
                this.readBlockGrip(template);
2✔
925

926
                grip.FlipExpressionId = this._mergedReaders.ReadBitLong();
2✔
927

928
                grip.DirectionX = this._mergedReaders.ReadBitDouble();
2✔
929
                grip.DirectionY = this._mergedReaders.ReadBitDouble();
2✔
930
                grip.DirectionZ = this._mergedReaders.ReadBitDouble();
2✔
931

932
                return template;
2✔
933
        }
2✔
934

935
        private CadTemplate readLinearGrip()
936
        {
286✔
937
                var grip = new BlockLinearGrip();
286✔
938
                var template = new CadBlockGripTemplate(grip);
286✔
939

940
                this.readBlockGrip(template);
286✔
941

942
                grip.DistanceX = this._mergedReaders.ReadBitDouble();
286✔
943
                grip.DistanceY = this._mergedReaders.ReadBitDouble();
286✔
944
                grip.DistanceZ = this._mergedReaders.ReadBitDouble();
286✔
945

946
                return template;
286✔
947
        }
286✔
948

949
        private BlockLookupAction.ColumnData readLookupActionColumn()
950
        {
10✔
951
                BlockLookupAction.ColumnData col = new BlockLookupAction.ColumnData();
10✔
952

953
                col.NodeId = this._mergedReaders.ReadBitLong();
10✔
954
                col.ValueType = this._mergedReaders.ReadBitLong();
10✔
955
                col.Type = this._mergedReaders.ReadBitLong();
10✔
956
                col.IsLookupProperty = this._mergedReaders.ReadBit();
10✔
957
                col.UnmatchedName = this._mergedReaders.ReadVariableText();
10✔
958
                col.IsReadOnly = !this._mergedReaders.ReadBit();
10✔
959
                col.ConnectionName = this._mergedReaders.ReadVariableText();
10✔
960

961
                return col;
10✔
962
        }
10✔
963

964
        private CadTemplate readMTextAttributeObjectContextData()
965
        {
×
966
                //TODO: MTextAttributeObjectContextData for dwg
967
                MTextAttributeObjectContextData contextData = new();
×
968
                CadAnnotScaleObjectContextDataTemplate template = new CadAnnotScaleObjectContextDataTemplate(contextData);
×
969

970
                //this.readAnnotScaleObjectContextData(template);
971

972
                return null;
×
973
        }
×
974

975
        private void readObjectContextData(CadTemplate template)
976
        {
×
977
                this.readCommonNonEntityData(template);
×
978

979
                ObjectContextData contextData = (ObjectContextData)template.CadObject;
×
980

981
                //BS        70        Version (default value is 3).
982
                contextData.Version = _objectReader.ReadBitShort();
×
983
                //B        290        Default flag (default value is false).
984
                contextData.Default = _objectReader.ReadBit();
×
985
        }
×
986

987
        private ParameterValueSet readParameterValueSet()
988
        {
166✔
989
                ParameterValueSet valueSet = new ParameterValueSet();
166✔
990

991
                //96
992
                valueSet.Type = (ParameterValueSetType)this._mergedReaders.ReadBitLong();
166✔
993
                //141
994
                valueSet.Minimum = this._mergedReaders.ReadBitDouble();
166✔
995
                //142
996
                valueSet.Maximum = this._mergedReaders.ReadBitDouble();
166✔
997
                //143
998
                valueSet.Increment = this._mergedReaders.ReadBitDouble();
166✔
999

1000
                short numberOfValues = this._mergedReaders.ReadBitShort();
166✔
1001
                for (int i = 0; i < numberOfValues; i++)
332!
1002
                {
×
1003
                        valueSet.AllowedValues.Add(this._mergedReaders.ReadBitDouble());
×
1004
                }
×
1005

1006
                return valueSet;
166✔
1007
        }
166✔
1008

1009
        private CadBlockVisibilityParameterTemplate.StateTemplate readState()
1010
        {
568✔
1011
                CadBlockVisibilityParameterTemplate.StateTemplate template = new CadBlockVisibilityParameterTemplate.StateTemplate();
568✔
1012

1013
                template.State.Name = this._textReader.ReadVariableText();
568✔
1014

1015
                //DXF 94 subset count 1
1016
                int n1 = this._objectReader.ReadBitLong();
568✔
1017
                for (int i = 0; i < n1; i++)
2,024✔
1018
                {
444✔
1019
                        //332
1020
                        template.EntityHandles.Add(this.handleReference());
444✔
1021
                }
444✔
1022

1023
                //DXF 95 subset count 2
1024
                var n2 = this._objectReader.ReadBitLong();
568✔
1025
                for (int i = 0; i < n2; i++)
4,496✔
1026
                {
1,680✔
1027
                        //333
1028
                        template.ExpressionHandles.Add(this.handleReference());
1,680✔
1029
                }
1,680✔
1030

1031
                return template;
568✔
1032
        }
568✔
1033
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc