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

DomCR / ACadSharp / 17911350546

22 Sep 2025 09:46AM UTC coverage: 78.416% (-0.05%) from 78.47%
17911350546

Pull #191

github

web-flow
Merge 162578dff into 664767d0d
Pull Request #191: Solid3D entity

6700 of 9281 branches covered (72.19%)

Branch coverage included in aggregate %.

25899 of 32291 relevant lines covered (80.21%)

108633.97 hits per line

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

77.27
/src/ACadSharp/Tables/DimensionStyle.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Types.Units;
3
using System;
4

5
//        TODO should the described coupling of properties be implemented in this class,
6
//                 e.g., GenerateTolerances and LimitsGeneration?
7

8
namespace ACadSharp.Tables
9
{
10
        /// <summary>
11
        /// Represents a <see cref="DimensionStyle"/> table entry.
12
        /// </summary>
13
        /// <remarks>
14
        /// Object name <see cref="DxfFileToken.TableDimstyle"/> <br/>
15
        /// Dxf class name <see cref="DxfSubclassMarker.DimensionStyle"/>
16
        /// </remarks>
17
        [DxfName(DxfFileToken.TableDimstyle)]
18
        [DxfSubClass(DxfSubclassMarker.DimensionStyle)]
19
        public class DimensionStyle : TableEntry
20
        {
21
                public static DimensionStyle Default { get { return new DimensionStyle(DefaultName); } }
30,633✔
22

23
                /// <summary>
24
                /// Specifies a text prefix or suffix (or both) to the alternate dimension
25
                /// measurement for all types of dimensions except angular
26
                /// (see DIMAPOST System Variable).
27
                /// </summary>
28
                /// <remarks><para>
29
                /// For instance, if the current units are Architectural, <see cref="AlternateUnitDimensioning"/>
30
                /// is on (true), <see cref="AlternateUnitScaleFactor"/> is 25.4 (the number of millimeters per inch),
31
                /// <see cref="AlternateUnitDecimalPlaces"/> is 2, and <i>AlternateDimensioningSuffix</i> is set to "mm",
32
                /// a distance of 10 units would be displayed as 10"[254.00mm].
33
                /// </para><para>
34
                /// To turn off an established prefix or suffix (or both), set it to a single period (.).
35
                /// </para>
36
                /// </remarks>
37
                [DxfCodeValue(4)]
38
                public string AlternateDimensioningSuffix { get; set; } = "[]";
17,537✔
39

40
                /// <summary>
41
                /// Controls the number of decimal places in alternate units
42
                /// (see DIMALTD System Variable).
43
                /// </summary>
44
                /// <remarks>
45
                /// If <see cref="AlternateUnitDimensioning"/> is turned on (true), <i>AlternateUnitDecimalPlaces</i>
46
                /// specifies the number of digits displayed to the right of the decimal point in the alternate
47
                /// measurement.
48
                /// </remarks>
49
                [DxfCodeValue(171)]
50
                public short AlternateUnitDecimalPlaces { get; set; } = 3;
17,995✔
51

52
                /// <summary>Controls the display of alternate units in dimensions
53
                /// (see DIMALT System Variable).
54
                /// </summary>
55
                /// <value>
56
                /// <b>true</b> enables alternate units; <b>false</b> disables alternate units.
57
                /// </value>
58
                [DxfCodeValue(170)]
59
                public bool AlternateUnitDimensioning { get; set; } = false;
17,539✔
60

61
                /// <summary>
62
                /// Gets or sets the units format for alternate units of all dimension sub-styles
63
                /// except Angular
64
                /// (see DIMALTU System Variable).
65
                /// </summary>
66
                [DxfCodeValue(273)]
67
                public LinearUnitFormat AlternateUnitFormat { get; set; } = LinearUnitFormat.Decimal;
17,269✔
68

69
                /// <summary>
70
                /// Rounds off the alternate dimension units
71
                /// (see DIMALTRND System Variable).
72
                /// </summary>
73
                [DxfCodeValue(148)]
74
                public double AlternateUnitRounding { get; set; } = 0.0d;
17,116✔
75

76
                /// <summary>
77
                /// Controls the multiplier for alternate units
78
                /// (see DIMALTF System Variable).
79
                /// </summary>
80
                /// <remarks>
81
                /// If <see cref="AlternateUnitDimensioning"/> is turned on (true), the value of this
82
                /// property (AlternateUnitScaleFactor) multiplies linear dimensions by a factor to produce
83
                /// a value in an alternate system of measurement. The initial value represents the number
84
                /// of millimeters in an inch.
85
                /// </remarks>
86
                [DxfCodeValue(143)]
87
                public double AlternateUnitScaleFactor { get; set; } = 25.4;
17,995✔
88

89
                /// <summary>
90
                /// Gets or sets the number of decimal places for the tolerance values in the alternate
91
                /// units of a dimension
92
                /// (see DIMALTTD System Variable).
93
                /// </summary>
94
                [DxfCodeValue(274)]
95
                public short AlternateUnitToleranceDecimalPlaces { get; set; } = 3;
17,727✔
96

97
                /// <summary>
98
                /// Controls suppression of zeros in tolerance values
99
                /// (see DIMALTTZ System Variable).
100
                /// </summary>
101
                [DxfCodeValue(286)]
102
                public ZeroHandling AlternateUnitToleranceZeroHandling { get; set; } = ZeroHandling.SuppressZeroFeetAndInches;
17,269✔
103

104
                /// <summary>
105
                /// Controls the suppression of zeros for alternate unit dimension values
106
                /// (see DIMALTZ System Variable).
107
                /// </summary>
108
                [DxfCodeValue(285)]
109
                public ZeroHandling AlternateUnitZeroHandling { get; set; } = ZeroHandling.SuppressZeroFeetAndInches;
17,269✔
110

111
                /// <summary>
112
                /// Controls the number of precision places displayed in angular dimensions
113
                /// (see DIMADEC System Variable).
114
                /// </summary>
115
                /// <value><para>
116
                /// <b>-1</b>: Angular dimensions display the number of decimal places specified by
117
                /// the <see cref="DecimalPlaces"/> property
118
                /// </para><para>
119
                /// <b>0-8</b>: Specifies the number of decimal places displayed in angular dimensions
120
                /// (independent of the value of the <see cref="DecimalPlaces"/> property).
121
                /// </para>
122
                /// </value>
123
                [DxfCodeValue(179)]
124
                public short AngularDecimalPlaces { get; set; } = 0;
17,338✔
125

126
                /// <summary>
127
                /// Gets or sets the units format for angular dimensions
128
                /// (see DIMAUNIT System Variable).
129
                /// </summary>
130
                [DxfCodeValue(275)]
131
                public AngularUnitFormat AngularUnit { get; set; } = AngularUnitFormat.DecimalDegrees;
17,259✔
132

133
                /// <summary>
134
                /// Suppresses zeros for angular dimensions
135
                /// (see DIMAZIN System Variable).
136
                /// </summary>
137
                [DxfCodeValue(79)]
138
                public ZeroHandling AngularZeroHandling { get; set; } = ZeroHandling.SuppressZeroFeetAndInches;
17,209✔
139

140
                /// <summary>
141
                /// Controls display of the arc symbol in an arc length dimension
142
                /// (see DIMARCSYM System Variable).
143
                /// </summary>
144
                [DxfCodeValue(90)]
145
                public ArcLengthSymbolPosition ArcLengthSymbolPosition { get; set; } = ArcLengthSymbolPosition.BeforeDimensionText;
17,068✔
146

147
                /// <summary>
148
                /// Gets or sets the arrowhead block displayed at the ends of dimension lines
149
                /// (see DIMBLK System Variable).
150
                /// </summary>
151
                /// <value>
152
                /// A <see cref="BlockRecord"/> that makes up an arrowhead or null if the default,
153
                /// closed-filled arrowhead is to be displayed.
154
                /// </value>
155
                /// <remarks>
156
                /// <para>
157
                /// Note: Annotative blocks cannot be used as custom arrowheads for dimensions or leaders.
158
                /// </para>
159
                /// </remarks>
160
                [DxfCodeValue(DxfReferenceType.Handle, 342)]
161
                public BlockRecord ArrowBlock
162
                {
163
                        get { return this._dimArrowBlock; }
13,335✔
164
                        set
165
                        {
378✔
166
                                this._dimArrowBlock = CadObject.updateCollection(value, this.Document?.BlockRecords);
378✔
167
                        }
378✔
168
                }
169

170
                /// <summary>
171
                /// Controls the size of dimension line and leader line arrowheads. Also controls the
172
                /// size of hook lines
173
                /// (see DIMASZ System Variable).
174
                /// </summary>
175
                [DxfCodeValue(41)]
176
                public double ArrowSize
177
                {
178
                        get { return this._arrowSize; }
3,573✔
179
                        set
180
                        {
1,981✔
181
                                if (value < 0)
1,981!
182
                                {
×
183
                                        throw new ArgumentOutOfRangeException(nameof(value), value, $"The {nameof(this.ArrowSize)} must be equals or greater than zero.");
×
184
                                }
185
                                this._arrowSize = value;
1,981✔
186
                        }
1,981✔
187
                }
188

189
                /// <summary>
190
                /// Controls drawing of circle or arc center marks and centerlines by the
191
                /// DIMCENTER, DIMDIAMETER, and DIMRADIUS commands
192
                /// (see DIMCEN System Variable).
193
                /// </summary>
194
                /// <remarks>
195
                /// For DIMDIAMETER and DIMRADIUS, the center mark is drawn only if you place
196
                /// the dimension line outside the circle or arc.
197
                /// </remarks>
198
                /// <value>
199
                /// <para>
200
                /// <b>0</b>
201
                /// </para><para>
202
                /// No center marks or lines are drawn
203
                /// </para><para>
204
                /// <b>&lt;0</b>
205
                /// </para><para>
206
                /// Centerlines are drawn
207
                /// </para><para>
208
                /// <b>&gt;0</b>
209
                /// </para><para>
210
                /// Center marks are drawn
211
                /// </para>
212
                /// </value>
213
                [DxfCodeValue(141)]
214
                public double CenterMarkSize { get; set; } = 0.0900;
18,111✔
215

216
                /// <summary>
217
                /// Controls options for user-positioned text
218
                /// (see DIMUPT System Variable).
219
                /// </summary>
220
                /// <value>
221
                /// <para>
222
                /// <b>false</b>: Cursor controls only the dimension line location.
223
                /// </para><para>
224
                /// <b>true</b>: Cursor controls both the text position and the dimension line location,
225
                /// </para>
226
                /// </value>
227
                [DxfCodeValue(288)]
228
                public bool CursorUpdate { get; set; } = false;
17,271✔
229

230
                /// <summary>
231
                /// Gets or sets the number of decimal places displayed for the primary
232
                /// units of a dimension
233
                /// (see DIMDEC System Variable).
234
                /// </summary>
235
                [DxfCodeValue(271)]
236
                public short DecimalPlaces { get; set; } = 2;
17,824✔
237

238
                /// <summary>
239
                /// Specifies a single-character decimal separator to use when creating dimensions whose unit
240
                /// format is decimal
241
                /// (see DIMDSEP System Variable).
242
                /// </summary>
243
                /// <remarks>
244
                /// When prompted, enter a single character at the Command prompt. If dimension units is set
245
                /// to Decimal, the <i>DecimalSeparator</i> character is used instead of the default decimal point.
246
                /// If <i>DecimalSeparator</i> is set to NULL (default value), the decimal point is used as
247
                /// the dimension separator.
248
                /// </remarks>
249
                [DxfCodeValue(278)]
250
                public char DecimalSeparator { get; set; } = '.';
17,669✔
251

252
                /// <summary>
253
                /// Gets or sets the arrowhead for the first end of the dimension line when
254
                /// <see cref="SeparateArrowBlocks"/> is on (true)
255
                /// (see DIMBLK1 System Variable).
256
                /// </summary>
257
                /// <value>
258
                /// A <see cref="BlockRecord"/> that makes up an arrowhead or null if the default,
259
                /// closed-filled arrowhead is to be displayed.
260
                /// </value>
261
                /// <remarks>
262
                /// <para>
263
                /// Note: Annotative blocks cannot be used as custom arrowheads for dimensions or leaders.
264
                /// </para>
265
                /// </remarks>
266
                [DxfCodeValue(DxfReferenceType.Handle, 343)]
267
                public BlockRecord DimArrow1
268
                {
269
                        get { return this._dimArrow1; }
13,530✔
270
                        set
271
                        {
378✔
272
                                this._dimArrow1 = CadObject.updateCollection(value, this.Document?.BlockRecords);
378✔
273
                        }
378✔
274
                }
275

276
                /// <summary>
277
                /// Gets or sets the arrowhead for the first end of the dimension line when
278
                /// <see cref="SeparateArrowBlocks"/> is on (true)
279
                /// (see DIMBLK2 System Variable).
280
                /// </summary>
281
                /// <value>
282
                /// A <see cref="BlockRecord"/> that makes up an arrowhead or null if the default,
283
                /// closed-filled arrowhead is to be displayed.
284
                /// </value>
285
                /// <remarks>
286
                /// <para>
287
                /// Note: Annotative blocks cannot be used as custom arrowheads for dimensions or leaders.
288
                /// </para>
289
                /// </remarks>
290
                [DxfCodeValue(DxfReferenceType.Handle, 344)]
291
                public BlockRecord DimArrow2
292
                {
293
                        get { return this._dimArrow2; }
13,530✔
294
                        set
295
                        {
378✔
296
                                this._dimArrow2 = CadObject.updateCollection(value, this.Document?.BlockRecords);
378✔
297
                        }
378✔
298
                }
299

300
                /// <summary>
301
                /// Determines how dimension text and arrows are arranged when space is not sufficient to
302
                /// place both within the extension lines.
303
                /// (see DIMFIT System Variable).
304
                /// </summary>
305
                [DxfCodeValue(287)]
306
                public short DimensionFit { get; set; }
1,340✔
307

308
                /// <summary>
309
                /// Gets or sets colors to dimension lines, arrowheads, and dimension leader lines
310
                /// (see DIMCLRD System Variable).
311
                /// </summary>
312
                /// <remarks>
313
                /// Also controls the color of leader lines created with the LEADER command.
314
                /// </remarks>
315
                [DxfCodeValue(176)]
316
                public Color DimensionLineColor { get; set; } = Color.ByBlock;
18,094✔
317

318
                /// <summary>
319
                /// Sets the distance the dimension line extends beyond the extension line when
320
                /// oblique strokes are drawn instead of arrowheads.
321
                /// (see DIMDLE System Variable).
322
                /// </summary>
323
                [DxfCodeValue(46)]
324
                public double DimensionLineExtension { get; set; } = 0.0d;
17,539✔
325

326
                /// <summary>
327
                /// Gets or sets the distance around the dimension text when the dimension line breaks to
328
                /// accommodate dimension text
329
                /// (see DIMGAP System Variable).
330
                /// </summary>
331
                /// <remarks>
332
                /// <para>
333
                /// Also sets the gap between annotation and a hook line created with the LEADER command.
334
                /// If you enter a negative value, <i>DimensionLineGap</i> places a box around the dimension text.
335
                /// </para><para>
336
                /// The value of <i>DimensionLineGap</i> is also used as the minimum length of each segment
337
                /// of the dimension line. To locate the components of a linear dimension within the extension
338
                /// lines, enough space must be available for both arrowheads (2 x <see cref="ArrowSize"/>),
339
                /// both dimension line segments (2 x <i>DimensionLineGap</i>), a gap on either side of the
340
                /// dimension text (another 2 x <i>DimensionLineGap</i>), and the length of the dimension text,
341
                /// which depends on its size and number of decimal places displayed.
342
                /// </para>
343
                /// </remarks>
344
                [DxfCodeValue(147)]
345
                public double DimensionLineGap { get; set; } = 0.6250;
18,166✔
346

347
                /// <summary>
348
                /// Controls the spacing of the dimension lines in baseline dimensions
349
                /// (see DIMDLI System Variable).
350
                /// </summary>
351
                /// <remarks>
352
                /// Each dimension line is offset from the previous one by this amount, if necessary,
353
                /// to avoid drawing over it. Changes made with <i>DimensionLineIncrement</i> are
354
                /// not applied to existing dimensions.
355
                /// </remarks>
356
                [DxfCodeValue(43)]
357
                public double DimensionLineIncrement { get; set; } = 3.75d;
17,995✔
358

359
                /// <summary>
360
                /// Assigns line weight to dimension lines
361
                /// (see DIMLWD System Variable).
362
                /// </summary>
363
                /// <value>
364
                /// Positive values represent line weight in hundredths of millimeters.
365
                /// (Multiply a value by 2540 to convert values from inches to hundredths of millimeters.)
366
                /// </value>
367
                [DxfCodeValue(371)]
368
                public LineWeightType DimensionLineWeight { get; set; } = LineWeightType.ByBlock;
17,434✔
369

370
                /// <summary>
371
                /// Determines how dimension text and arrows are arranged when space is not sufficient
372
                /// to place both within the extension lines.
373
                /// (see DIMATFIT System Variable).
374
                /// </summary>
375
                /// <remarks>
376
                /// A leader is added to moved dimension text when <see cref="TextMovement"/> is set to
377
                /// <see cref="TextMovement.AddLeaderWhenTextMoved"/>.
378
                /// </remarks>
379
                [DxfCodeValue(289)]
380
                public TextArrowFitType DimensionTextArrowFit { get; set; } = TextArrowFitType.BestFit;
16,133✔
381

382
                //Obsolete in the documentation
383
                /// <summary>
384
                /// DIMUNIT (obsolete, now use DIMLUNIT AND DIMFRAC)
385
                /// </summary>
386
                [DxfCodeValue(270)]
387
                public short DimensionUnit { get; set; } = 2;
15,180✔
388

389
                /// <summary>
390
                /// Gets or sets colors to extension lines, center marks, and centerlines
391
                /// (see DIMCLRE System Variable).
392
                /// </summary>
393
                [DxfCodeValue(177)]
394
                public Color ExtensionLineColor { get; set; } = Color.ByBlock;
18,188✔
395

396
                /// <summary>
397
                /// Specifies how far to extend the extension line beyond the dimension line
398
                /// (see DIMEXE System Variable).
399
                /// </summary>
400
                [DxfCodeValue(44)]
401
                public double ExtensionLineExtension { get; set; } = 1.2500d;
18,060✔
402

403
                /// <summary>
404
                /// Specifies how far extension lines are offset from origin points
405
                /// (see DIMEXO System Variable).
406
                /// </summary>
407
                /// <remarks>
408
                /// With fixed-length extension lines, this value determines the minimum offset.
409
                /// </remarks>
410
                [DxfCodeValue(42)]
411
                public double ExtensionLineOffset { get; set; } = 0.6250d;
18,070✔
412

413
                /// <summary>
414
                /// Assigns line weight to extension lines
415
                /// (see DIMLWE System Variable).
416
                /// </summary>
417
                /// <value>
418
                /// Positive values represent line weight in hundredths of millimeters.
419
                /// (Multiply a value by 2540 to convert values from inches to hundredths of millimeters.)
420
                /// </value>
421
                [DxfCodeValue(372)]
422
                public LineWeightType ExtensionLineWeight { get; set; } = LineWeightType.ByBlock;
17,300✔
423

424
                /// <summary>
425
                /// Sets the total length of the extension lines starting from the dimension line
426
                /// toward the dimension origin
427
                /// (see DIMFXL System Variable).
428
                /// </summary>
429
                [DxfCodeValue(49)]
430
                public double FixedExtensionLineLength { get; set; } = 1.0d;
16,613✔
431

432
                /// <summary>
433
                /// Gets or sets the fraction format when <see cref="LinearUnitFormat"/> is set to 4 (Architectural) or 5 (Fractional).
434
                /// (see DIMFRAC System Variable).
435
                /// </summary>
436
                [DxfCodeValue(276)]
437
                public FractionFormat FractionFormat { get; set; } = FractionFormat.Horizontal;
17,211✔
438

439
                /// <summary>
440
                /// Appends tolerances to dimension text
441
                /// (see DIMTOL System Variable).
442
                /// </summary>
443
                /// <remarks>
444
                /// Setting <i>GenerateTolerances</i> to on (true) turns <see cref="LimitsGeneration"/> off (false).
445
                /// </remarks>
446
                [DxfCodeValue(71)]
447
                public bool GenerateTolerances { get; set; } = false;
17,539✔
448

449
                /// <summary>
450
                /// Controls whether extension lines are set to a fixed length
451
                /// (see DIMFXLON System Variable).
452
                /// </summary>
453
                /// <value>
454
                /// <b>true</b> when extension lines are set to the length specified by
455
                /// <see cref="FixedExtensionLineLength"/>; otherwise, <b>false</b>.
456
                /// </value>
457
                [DxfCodeValue(290)]
458
                public bool IsExtensionLineLengthFixed { get; set; } = false;
16,613✔
459

460
                /// <summary>
461
                /// Determines the angle of the transverse segment of the dimension line in a jogged radius dimension in radians.
462
                /// (see DIMJOGANG System Variable).
463
                /// </summary>
464
                /// <value>
465
                /// Jogged radius dimensions are often created when the center point is located off the page. Valid settings range is 5 to 90 degrees.
466
                /// </value>
467
                [DxfCodeValue(DxfReferenceType.IsAngle, 50)]
468
                public double JoggedRadiusDimensionTransverseSegmentAngle
469
                {
470
                        get
471
                        {
844✔
472
                                return this._joggedRadiusDimensionTransverseSegmentAngle;
844✔
473
                        }
844✔
474
                        set
475
                        {
748✔
476
                                //5 - 90
477
                                if (value < CSMath.MathHelper.DegToRad(5) || value > Math.PI / 2)
748!
478
                                {
×
479
                                        throw new ArgumentOutOfRangeException(nameof(value), value, $"The {nameof(this.JoggedRadiusDimensionTransverseSegmentAngle)} must be in range of 5 to 90 degrees.");
×
480
                                }
481

482
                                this._joggedRadiusDimensionTransverseSegmentAngle = value;
748✔
483
                        }
748✔
484
                }
485

486
                /// <summary>
487
                /// Specifies the arrow type for leaders
488
                /// (see DIMLDRBLK System Variable).
489
                /// </summary>
490
                /// <value>
491
                /// A <see cref="BlockRecord"/> that makes up an arrowhead or null if the default,
492
                /// closed-filled arrowhead is to be displayed.
493
                /// </value>
494
                /// <remarks>
495
                /// Note: Annotative blocks cannot be used as custom arrowheads for dimensions or leaders.
496
                /// </remarks>
497
                [DxfCodeValue(DxfReferenceType.Handle, 341)]
498
                public BlockRecord LeaderArrow
499
                {
500
                        get { return this._leaderArrow; }
13,314✔
501
                        set
502
                        {
378✔
503
                                this._leaderArrow = CadObject.updateCollection(value, this.Document?.BlockRecords);
378✔
504
                        }
378✔
505
                }
506

507
                /// <summary>
508
                /// Generates dimension limits as the default text
509
                /// (see DIMLIM System Variable).
510
                /// </summary>
511
                /// <remarks>
512
                /// Setting <i>LimitsGeneration</i> to on (true) turns <see cref="GenerateTolerances"/> off (false).
513
                /// </remarks>
514
                [DxfCodeValue(72)]
515
                public bool LimitsGeneration { get; set; } = false;
17,539✔
516

517
                /// <summary>
518
                /// Sets a scale factor for linear dimension measurements
519
                /// (see DIMLFAC System Variable).
520
                /// </summary>
521
                /// <remarks>
522
                /// <para>
523
                /// All linear dimension distances, including radii, diameters, and coordinates, are multiplied
524
                /// by this <i>LinearScaleFactor</i> before being converted to dimension text.
525
                /// Positive values of <i>LinearScaleFactor</i> are applied to dimensions in both model space and
526
                /// paper space; negative values are applied to paper space only.
527
                /// </para><para>
528
                /// <i>LinearScaleFactor</i> applies primarily to non-associative dimensions (DIMASSOC set 0 or 1).
529
                /// For non-associative dimensions in paper space, <i>LinearScaleFactor</i> must be set individually
530
                /// for each layout viewport to accommodate viewport scaling.
531
                /// </para><para>
532
                /// <i>LinearScaleFactor</i> has no effect on angular dimensions, and is not applied to the values held in
533
                /// <see cref="Rounding"/>, <see cref="MinusTolerance"/>, or <see cref="PlusTolerance"/>.
534
                /// </para>
535
                /// </remarks>
536
                [DxfCodeValue(144)]
537
                public double LinearScaleFactor { get; set; } = 1.0;
17,539✔
538

539
                /// <summary>
540
                /// Gets or sets units for all dimension types except Angular
541
                /// (see DIMLUNIT System Variable).
542
                /// </summary>
543
                [DxfCodeValue(277)]
544
                public LinearUnitFormat LinearUnitFormat { get; set; } = LinearUnitFormat.Decimal;
17,201✔
545

546
                /// <summary>
547
                /// Line type for the main line of the dimension.
548
                /// </summary>
549
                [DxfCodeValue(DxfReferenceType.Handle, 345)]
550
                public LineType LineType
551
                {
552
                        get { return this._lineType; }
12,009✔
553
                        set
554
                        {
605✔
555
                                this._lineType = CadObject.updateCollection(value, this.Document?.LineTypes);
605✔
556
                        }
605✔
557
                }
558

559
                /// <summary>
560
                /// Line type for the extension line 1.
561
                /// </summary>
562
                [DxfCodeValue(DxfReferenceType.Handle, 346)]
563
                public LineType LineTypeExt1
564
                {
565
                        get { return this._lineTypeExt1; }
11,922✔
566
                        set
567
                        {
596✔
568
                                this._lineTypeExt1 = CadObject.updateCollection(value, this.Document?.LineTypes);
596✔
569
                        }
596✔
570
                }
571

572
                /// <summary>
573
                /// Line type for the extension line 2.
574
                /// </summary>
575
                [DxfCodeValue(DxfReferenceType.Handle, 347)]
576
                public LineType LineTypeExt2
577
                {
578
                        get { return this._lineTypeExt2; }
11,922✔
579
                        set
580
                        {
596✔
581
                                this._lineTypeExt2 = CadObject.updateCollection(value, this.Document?.LineTypes);
596✔
582
                        }
596✔
583
                }
584

585
                /// <summary>
586
                /// Gets or sets the minimum (or lower) tolerance limit for dimension text when
587
                /// <see cref="GenerateTolerances"/> or <see cref="LimitsGeneration"/> is on (true).
588
                /// (see DIMTM System Variable).
589
                /// </summary>
590
                /// <remarks>
591
                /// <para>
592
                /// <i>MinusTolerance</i> accepts signed values. If <see cref="GenerateTolerances"/> is on
593
                /// and <see cref="PlusTolerance"/> and <i>MinusTolerance</i> are set to the same value,
594
                /// a tolerance value is drawn.
595
                /// </para><para>
596
                /// If <i>MinusTolerance</i> and <see cref="PlusTolerance"/> values differ, the upper
597
                /// tolerance is drawn above the lower, and a plus sign is added to the <see cref="PlusTolerance"/>
598
                /// value if it is positive.
599
                /// </para><para>
600
                /// For <i>MinusTolerance</i>, the program uses the negative of the value you enter
601
                /// (adding a minus sign if you specify a positive number and a plus sign if you specify a negative
602
                /// number).
603
                /// </para>
604
                /// </remarks>
605
                [DxfCodeValue(48)]
606
                public double MinusTolerance { get; set; } = 0.0d;
17,539✔
607

608
                /// <inheritdoc/>
609
                public override string ObjectName => DxfFileToken.TableDimstyle;
26,461✔
610

611
                /// <inheritdoc/>
612
                public override ObjectType ObjectType => ObjectType.DIMSTYLE;
548✔
613

614
                /// <summary>
615
                /// Gets or sets the maximum (or upper) tolerance limit for dimension text when
616
                /// <see cref="GenerateTolerances"/> or <see cref="LimitsGeneration"/> is on (true)
617
                /// (see DIMTP System Variable).
618
                /// </summary>
619
                [DxfCodeValue(47)]
620
                public double PlusTolerance { get; set; } = 0.0d;
17,539✔
621

622
                /// <summary>
623
                /// Specifies a text prefix or suffix (or both) to the dimension measurement
624
                /// (see DIMPOST System Variable).
625
                /// </summary>
626
                /// <remarks><para>
627
                /// For example, to establish a suffix for millimeters, set <i>PostFix</i> to mm;
628
                /// a distance of 19.2 units would be displayed as 19.2 mm.
629
                /// </para><para>
630
                /// If tolerances are turned on, the suffix is applied to the tolerances
631
                /// as well as to the main dimension.
632
                /// </para><para>
633
                /// Use &lt;&gt; to indicate placement of the text in relation to the dimension value.
634
                /// For example, enter &lt;&gt; mm to display a 5.0 millimeter radial dimension as "5.0mm".
635
                /// If you entered mm &lt;&gt;, the dimension would be displayed as "mm 5.0". Use the &lt;&gt;
636
                /// mechanism for angular dimensions.
637
                /// </para>
638
                /// </remarks>
639
                [DxfCodeValue(3)]
640
                public string PostFix { get; set; } = "<>";
17,731✔
641

642
                /// <summary>
643
                /// Gets or sets the prefix based on the <see cref="PostFix"/> value.
644
                /// </summary>
645
                public string Prefix
646
                {
647
                        get
648
                        {
97✔
649
                                this.getDimStylePrefixAndSuffix(this.PostFix, '<', '>', out string prefix, out _);
97✔
650
                                return prefix;
97✔
651
                        }
97✔
652
                        set
653
                        {
×
654
                                this.getDimStylePrefixAndSuffix(this.PostFix, '<', '>', out _, out string suffix);
×
655
                                this.PostFix = $"{value}{this.PostFix}{suffix}";
×
656
                        }
×
657
                }
658

659
                /// <summary>
660
                /// Rounds all dimensioning distances to the specified value
661
                /// (see DIMRND System Variable).
662
                /// </summary>
663
                /// <remarks>
664
                /// <para>
665
                /// For instance, if <i>Rounding</i> is set to 0.25, all distances round
666
                /// to the nearest 0.25 unit. If you set the value to 1.0, all distances round to the
667
                /// nearest integer.
668
                /// </para><para>
669
                /// Note that the number of digits edited after the decimal point depends on the
670
                /// precision set by <see cref="DecimalPlaces"/>.
671
                /// </para><para>
672
                /// This  does not apply to angular dimensions.
673
                /// </para>
674
                /// </remarks>
675
                [DxfCodeValue(45)]
676
                public double Rounding { get; set; } = 0.0d;
17,648✔
677

678
                /// <summary>
679
                /// Gets or sets the overall scale factor applied to dimensioning variables that specify
680
                /// sizes, distances, or offsets
681
                /// (see DIMSCALE System Variable).
682
                /// </summary>
683
                /// <remarks>
684
                /// <para>
685
                /// This ScaleFactor does not affect measured lengths, coordinates, or angles.
686
                /// </para><para>
687
                /// Use <i>ScaleFactor</i> to control the overall scale of dimensions. However, if the current
688
                /// dimension style is annotative, <i>ScaleFactor</i> is automatically set to zero and the
689
                /// dimension scale is controlled by the CANNOSCALE system variable. <i>ScaleFactor</i> cannot
690
                /// be set to a non-zero value when using annotative dimensions.
691
                /// </para><para>
692
                /// Also affects the leader objects with the LEADER command.
693
                /// </para><para>
694
                /// Use MLEADERSCALE to scale multileader objects created with the MLEADER command.
695
                /// </para>
696
                /// </remarks>
697
                /// <value>
698
                /// <para>
699
                /// <b>1.0</b>
700
                /// </para><para>
701
                /// A reasonable default value is computed based on the scaling between the current
702
                /// model space viewport and paper space. If you are in paper space or model space
703
                /// and not using the paper space feature, the scale factor is 1.0.
704
                /// </para><para>
705
                /// <b>&gt;0</b>
706
                /// </para><para>
707
                /// A scale factor is computed that leads text sizes, arrowhead sizes, and other scaled
708
                /// distances to plot at their face values.
709
                /// </para>
710
                /// </value>
711
                [DxfCodeValue(40)]
712
                public double ScaleFactor
713
                {
714
                        get => this._scaleFactor; set
1,483✔
715
                        {
1,983✔
716
                                if (value < 0)
1,983!
717
                                {
×
718
                                        throw new ArgumentOutOfRangeException(nameof(value), value, $"The {nameof(this.ScaleFactor)} must be equals or greater than zero.");
×
719
                                }
720

721
                                this._scaleFactor = value;
1,983✔
722
                        }
1,983✔
723
                }
724

725
                /// <summary>
726
                /// Controls the display of dimension line arrowhead blocks
727
                /// (see DIMSAH System Variable).
728
                /// </summary>
729
                /// <value>
730
                /// <b>true</b> if arrowhead blocks set by <see cref="DimArrow1"/> and <see cref="DimArrow2"/>
731
                /// shall be used;
732
                /// <b>false</b> if arrowhead block set by <see cref="ArrowBlock"/> shall be used.
733
                /// </value>
734
                [DxfCodeValue(173)]
735
                public bool SeparateArrowBlocks { get; set; } = true;
17,539✔
736

737
                /// <summary>
738
                /// Specifies the text style of the dimension
739
                /// (see DIMTXSTY System Variable).
740
                /// </summary>
741
                [DxfCodeValue(DxfReferenceType.Handle, 340)]
742
                public TextStyle Style
743
                {
744
                        get { return this._style; }
13,353✔
745
                        set
746
                        {
2,504✔
747
                                if (value == null)
2,504!
748
                                {
×
749
                                        throw new ArgumentNullException(nameof(value));
×
750
                                }
751

752
                                this._style = CadObject.updateCollection(value, this.Document?.TextStyles);
2,504✔
753
                        }
2,504✔
754
                }
755

756
                /// <inheritdoc/>
757
                public override string SubclassMarker => DxfSubclassMarker.DimensionStyle;
34,225✔
758

759
                /// <summary>
760
                /// Gets or sets the suffix based on the <see cref="PostFix"/> value.
761
                /// </summary>
762
                public string Suffix
763
                {
764
                        get
765
                        {
97✔
766
                                this.getDimStylePrefixAndSuffix(this.PostFix, '<', '>', out _, out string suffix);
97✔
767
                                return suffix;
97✔
768
                        }
97✔
769
                        set
770
                        {
×
771
                                this.getDimStylePrefixAndSuffix(this.PostFix, '<', '>', out string prefix, out _);
×
772
                                this.PostFix = $"{prefix}{this.PostFix}{value}";
×
773
                        }
×
774
                }
775

776
                /// <summary>
777
                /// Controls suppression of the first dimension line and arrowhead
778
                /// (see DIMSD1 System Variable).
779
                /// </summary>
780
                /// <value>
781
                /// <b>true</b> if the first dimension line is to be suppressed; otherwise, <b>false</b>.
782
                /// </value>
783
                [DxfCodeValue(281)]
784
                public bool SuppressFirstDimensionLine { get; set; } = false;
16,964✔
785

786
                /// <summary>
787
                /// Suppresses display of the first extension line
788
                /// (see DIMSE1 System Variable).
789
                /// </summary>
790
                /// <value><b>true</b> if the first extension line is to be suppressed; otherwise <b>false</b>.
791
                /// </value>
792
                [DxfCodeValue(75)]
793
                public bool SuppressFirstExtensionLine { get; set; } = false;
18,005✔
794

795
                /// <summary>
796
                /// Suppresses arrowheads if not enough space is available inside the extension lines
797
                /// (see DIMSOXD System Variable).
798
                /// </summary>
799
                /// <value>
800
                /// <b>true</b> if arrowheads are to be suppressed; otherwise, <b>false</b>.
801
                /// </value>
802
                [DxfCodeValue(175)]
803
                public bool SuppressOutsideExtensions { get; set; } = false;
17,539✔
804

805
                /// <summary>
806
                /// Controls suppression of the second dimension line and arrowhead
807
                /// (see DIMSD2 System Variable).
808
                /// </summary>
809
                /// <value>
810
                /// <b>true</b> if the second dimension line is to be suppressed; otherwise, <b>false</b>.
811
                /// </value>
812
                [DxfCodeValue(282)]
813
                public bool SuppressSecondDimensionLine { get; set; } = false;
16,964✔
814

815
                /// <summary>
816
                /// Suppresses display of the second extension line
817
                /// (see DIMSE2 System Variable).
818
                /// </summary>
819
                /// <value><b>true</b> if the second extension line is to be suppressed; otherwise <b>false</b>.
820
                /// </value>
821
                [DxfCodeValue(76)]
822
                public bool SuppressSecondExtensionLine { get; set; } = false;
18,005✔
823

824
                /// <summary>
825
                /// Sets the color for the text background in dimensions.
826
                /// (see DIMTFILLCLR System Variable).
827
                /// </summary>
828
                //[DxfCodeValue(70)]        //Not present in the dxf documentation
829
                public Color TextBackgroundColor { get; set; } = Color.ByBlock;
16,328✔
830

831
                /// <summary>
832
                /// Controls the background of dimension text
833
                /// (see DIMTFILL System Variable).
834
                /// </summary>
835
                [DxfCodeValue(69)]
836
                public DimensionTextBackgroundFillMode TextBackgroundFillMode { get; set; } = DimensionTextBackgroundFillMode.NoBackground;
16,767✔
837

838
                /// <summary>
839
                /// Assigns colors to dimension text
840
                /// (see DIMCLRT System Variable).
841
                /// </summary>
842
                /// <remarks>
843
                /// The color can be any valid color number.
844
                /// </remarks>
845
                [DxfCodeValue(178)]
846
                public Color TextColor { get; set; } = Color.ByBlock;
17,772✔
847

848
                /// <summary>
849
                /// Specifies the reading direction of the dimension text
850
                /// (see DIMTXTDIRECTION System Variable).
851
                /// </summary>
852
                [DxfCodeValue(295)]
853
                public TextDirection TextDirection { get; set; } = TextDirection.LeftToRight;
15,961✔
854

855
                /// <summary>
856
                /// Specifies the height of dimension text, unless the current text style has a fixed height
857
                /// (see DIMTXT System Variable).
858
                /// </summary>
859
                [DxfCodeValue(140)]
860
                public double TextHeight
861
                {
862
                        get { return this._textHeight; }
3,291✔
863
                        set
864
                        {
1,981✔
865
                                if (value <= 0)
1,981!
866
                                {
×
867
                                        throw new ArgumentOutOfRangeException(nameof(value), value, $"The {nameof(this.TextHeight)} must be greater than zero.");
×
868
                                }
869

870
                                this._textHeight = value;
1,981✔
871
                        }
1,981✔
872
                }
873

874
                /// <summary>
875
                /// Controls the horizontal positioning of dimension text
876
                /// (see DIMJUST System Variable).
877
                /// </summary>
878
                [DxfCodeValue(280)]
879
                public DimensionTextHorizontalAlignment TextHorizontalAlignment { get; set; } = DimensionTextHorizontalAlignment.Centered;
17,269✔
880

881
                /// <summary>
882
                /// Draws text between extension lines
883
                /// (see DIMTIX System Variable).
884
                /// </summary>
885
                /// <value><para>
886
                /// <b>false</b>: For linear and angular dimensions, dimension text is placed
887
                /// inside the extension lines if there is sufficient room.
888
                /// </para><para>
889
                /// <b>true</b>: Draws dimension text between the extension lines even if it
890
                /// would ordinarily be placed outside those lines.
891
                /// For radius and diameter dimensions, TextInsideExtensions on (true) always forces
892
                /// the dimension text outside the circle or arc.
893
                /// </para>
894
                /// </value>
895
                [DxfCodeValue(174)]
896
                public bool TextInsideExtensions { get; set; } = false;
17,539✔
897

898
                /// <summary>
899
                /// Controls the position of dimension text inside the extension lines for all
900
                /// dimension types except Ordinate.
901
                /// (see DIMTIH System Variable).
902
                /// </summary>
903
                /// <value><b>true</b> if the text is to be drawn horizontally;
904
                /// <b>false </b> if the text is to be aligned with the dimension line.</value>
905
                [DxfCodeValue(73)]
906
                public bool TextInsideHorizontal { get; set; } = false;
17,995✔
907

908
                /// <summary>
909
                /// Sets dimension text movement rules
910
                /// (see DIMTMOVE System Variable).
911
                /// </summary>
912
                [DxfCodeValue(279)]
913
                public TextMovement TextMovement { get; set; } = TextMovement.MoveLineWithText;
17,112✔
914

915
                /// <summary>
916
                /// Controls whether a dimension line is drawn between the extension lines even when the text
917
                /// is placed outside.
918
                /// (see DIMTOFL System Variable).
919
                /// </summary>
920
                /// <remarks>
921
                /// For radius and diameter dimensions, a dimension line is drawn inside the circle or arc when the text,
922
                /// arrowheads, and leader are placed outside.
923
                /// </remarks>
924
                /// <value>
925
                /// <para>
926
                /// <b>true</b>: Draws dimension lines between the measured points even when arrowheads are placed
927
                /// outside the measured points
928
                /// </para><para>
929
                /// <b>false</b>: Does not draw dimension lines between the measured points when arrowheads are placed
930
                /// outside the measured points
931
                /// </para>
932
                /// </value>
933
                [DxfCodeValue(172)]
934
                public bool TextOutsideExtensions { get; set; }
2,974✔
935

936
                /// <summary>
937
                /// Controls the position of dimension text outside the extension lines
938
                /// (see DIMTOH System Variable).
939
                /// </summary>
940
                /// <value><b>true</b> if the text is to be drawn horizontally;
941
                /// <b>false </b> if the text is to be aligned with the dimension line.</value>
942
                [DxfCodeValue(74)]
943
                public bool TextOutsideHorizontal { get; set; } = false;
17,995✔
944

945
                /// <summary>
946
                /// Controls the vertical position of text in relation to the dimension line
947
                /// (see DIMTAD System Variable).
948
                /// </summary>
949
                [DxfCodeValue(77)]
950
                public DimensionTextVerticalAlignment TextVerticalAlignment { get; set; } = DimensionTextVerticalAlignment.Above;
17,993✔
951

952
                /// <summary>
953
                /// Controls the vertical position of dimension text above or below the dimension line
954
                /// (see DIMTVP System Variable).
955
                /// </summary>
956
                /// <remarks>
957
                /// The <i>TextVerticalPosition</i> value is used when <see cref="TextVerticalAlignment"/>
958
                /// is off. The magnitude of the vertical offset of text is the product of the text height
959
                /// and <i>TextVerticalPosition</i>. Setting <i>TextVerticalPosition</i> to 1.0 is equivalent
960
                /// to setting <see cref="TextVerticalAlignment"/> to on. The dimension line splits to
961
                /// accommodate the text only if the absolute value of <i>TextVerticalPosition</i> is less than 0.7.
962
                /// </remarks>
963
                [DxfCodeValue(145)]
964
                public double TextVerticalPosition { get; set; } = 0.0d;
17,539✔
965

966
                /// <summary>
967
                /// Specifies the size of oblique strokes drawn instead of arrowheads for linear, radius,
968
                /// and diameter dimensioning
969
                /// (see DIMTSZ System Variable).
970
                /// </summary>
971
                /// <value>
972
                /// <para>
973
                /// <b>0</b>
974
                /// </para><para>
975
                /// Draws arrowheads.
976
                /// </para><para>
977
                /// <b>&gt;0</b>
978
                /// </para><para>
979
                /// Draws oblique strokes instead of arrowheads.
980
                /// The size of the oblique strokes is determined by this value multiplied by the value
981
                /// of <see cref="ScaleFactor"/>.
982
                /// </para>
983
                /// </value>
984
                [DxfCodeValue(142)]
985
                public double TickSize { get; set; } = 0.0d;
17,539✔
986

987
                /// <summary>
988
                /// Gets or sets the vertical justification for tolerance values relative to the nominal dimension text.
989
                /// (see DIMTOLJ System Variable).
990
                /// </summary>
991
                [DxfCodeValue(283)]
992
                public ToleranceAlignment ToleranceAlignment { get; set; } = ToleranceAlignment.Bottom;
17,725✔
993

994
                /// <summary>
995
                /// Gets or sets the number of decimal places to display in tolerance values
996
                /// for the primary units in a dimension
997
                /// (see DIMTDEC System Variable).
998
                /// </summary>
999
                [DxfCodeValue(272)]
1000
                public short ToleranceDecimalPlaces { get; set; } = 2;
17,727✔
1001

1002
                /// <summary>
1003
                /// Specifies a scale factor for the text height of fractions and tolerance values relative
1004
                /// to the dimension text height, as set by <see cref="TextHeight"/>
1005
                /// (see DIMTFAC System Variable).
1006
                /// </summary>
1007
                /// <remarks>
1008
                /// For example, if <i>ToleranceScaleFactor</i> is set to 1.0, the text height of fractions and
1009
                /// tolerances is the same height as the dimension text. If <i>ToleranceScaleFactor</i> is set
1010
                /// to 0.7500, the text height of fractions and tolerances is three-quarters the size of
1011
                /// dimension text.
1012
                /// </remarks>
1013
                [DxfCodeValue(146)]
1014
                public double ToleranceScaleFactor { get; set; } = 1.0;
17,636✔
1015

1016
                /// <summary>
1017
                /// Controls the suppression of zeros in tolerance values
1018
                /// (see DIMTZIN System Variable).
1019
                /// </summary>
1020
                /// <remarks>
1021
                /// Value 0-3 affect feet-and-inch dimensions only.
1022
                /// </remarks>
1023
                [DxfCodeValue(284)]
1024
                public ZeroHandling ToleranceZeroHandling { get; set; } = ZeroHandling.SuppressDecimalTrailingZeroes;
17,725✔
1025

1026
                /// <summary>
1027
                /// Controls the suppression of zeros in the primary unit value
1028
                /// (see DIMZIN System Variable).
1029
                /// </summary>
1030
                [DxfCodeValue(78)]
1031
                public ZeroHandling ZeroHandling { get; set; } = ZeroHandling.SuppressDecimalTrailingZeroes;
18,090✔
1032

1033
                internal double AltMzf { get; set; }
819✔
1034

1035
                internal string AltMzs { get; set; }
819✔
1036

1037
                internal double Mzf { get; set; }
819✔
1038

1039
                internal string Mzs { get; set; }
819✔
1040

1041
                public const string DefaultName = "Standard";
1042

1043
                private double _arrowSize = 0.18;
15,021✔
1044

1045
                private BlockRecord _dimArrow1 = null;
15,021✔
1046

1047
                private BlockRecord _dimArrow2 = null;
15,021✔
1048

1049
                private BlockRecord _dimArrowBlock = null;
15,021✔
1050

1051
                private double _joggedRadiusDimensionTransverseSegmentAngle = System.Math.PI / 4.0;
15,021✔
1052

1053
                private BlockRecord _leaderArrow = null;
15,021✔
1054

1055
                private LineType _lineType;
1056

1057
                private LineType _lineTypeExt1;
1058

1059
                private LineType _lineTypeExt2;
1060

1061
                private double _scaleFactor = 1.0d;
15,021✔
1062

1063
                private TextStyle _style = TextStyle.Default;
15,021✔
1064

1065
                private double _textHeight = 0.18;
15,021✔
1066

1067
                /// <inheritdoc/>
1068
                public DimensionStyle(string name) : base(name)
12,565✔
1069
                {
12,565✔
1070
                }
12,565✔
1071

1072
                internal DimensionStyle() : base()
2,456✔
1073
                {
2,456✔
1074
                }
2,456✔
1075

1076
                /// <summary>
1077
                /// Apply the rounding of the style to the value.
1078
                /// </summary>
1079
                /// <param name="value">value to apply the style rounding.</param>
1080
                /// <param name="isAlternate">flag to indicate to use the alternate rounding.</param>
1081
                /// <returns></returns>
1082
                public double ApplyRounding(double value, bool isAlternate = false)
1083
                {
104✔
1084
                        double rounding = isAlternate ? this.AlternateUnitRounding : this.Rounding;
104✔
1085

1086
                        if (rounding != 0.0)
104✔
1087
                        {
5✔
1088
                                value = rounding * Math.Round(value / rounding);
5✔
1089
                        }
5✔
1090

1091
                        return value;
104✔
1092
                }
104✔
1093

1094
                /// <inheritdoc/>
1095
                public override CadObject Clone()
1096
                {
368✔
1097
                        DimensionStyle clone = (DimensionStyle)base.Clone();
368✔
1098

1099
                        clone.Style = (TextStyle)this.Style?.Clone();
368!
1100
                        clone.LeaderArrow = (BlockRecord)this.LeaderArrow?.Clone();
368!
1101
                        clone.ArrowBlock = (BlockRecord)this.ArrowBlock?.Clone();
368!
1102
                        clone.DimArrow1 = (BlockRecord)this.DimArrow1?.Clone();
368!
1103
                        clone.DimArrow2 = (BlockRecord)this.DimArrow2?.Clone();
368!
1104
                        clone.LineType = (LineType)this.LineType?.Clone();
368✔
1105
                        clone.LineTypeExt1 = (LineType)this.LineTypeExt1?.Clone();
368✔
1106
                        clone.LineTypeExt2 = (LineType)this.LineTypeExt2?.Clone();
368✔
1107

1108
                        return clone;
368✔
1109
                }
368✔
1110

1111
                /// <summary>
1112
                /// Get the alternate unit style format for this dimension style.
1113
                /// </summary>
1114
                /// <returns></returns>
1115
                public UnitStyleFormat GetAlternateUnitStyleFormat()
1116
                {
×
1117
                        return new UnitStyleFormat
×
1118
                        {
×
1119
                                LinearDecimalPlaces = this.AlternateUnitDecimalPlaces,
×
1120
                                AngularDecimalPlaces = this.AlternateUnitDecimalPlaces,
×
1121
                                DecimalSeparator = this.DecimalSeparator.ToString(),
×
1122
                                FractionHeightScale = this.ToleranceScaleFactor,
×
1123
                                FractionType = this.FractionFormat,
×
1124
                                LinearZeroHandling = this.AlternateUnitZeroHandling,
×
1125
                                AngularZeroHandling = this.AlternateUnitZeroHandling,
×
1126
                        };
×
1127
                }
×
1128

1129
                /// <summary>
1130
                /// Get the unit style format for this dimension style.
1131
                /// </summary>
1132
                /// <returns></returns>
1133
                public UnitStyleFormat GetUnitStyleFormat()
1134
                {
97✔
1135
                        return new UnitStyleFormat
97!
1136
                        {
97✔
1137
                                LinearDecimalPlaces = this.DecimalPlaces,
97✔
1138
                                AngularDecimalPlaces = this.AngularDecimalPlaces == -1 ? this.DecimalPlaces : this.AngularDecimalPlaces,
97✔
1139
                                DecimalSeparator = this.DecimalSeparator.ToString(),
97✔
1140
                                FractionHeightScale = this.ToleranceScaleFactor,
97✔
1141
                                FractionType = this.FractionFormat,
97✔
1142
                                LinearZeroHandling = this.ZeroHandling,
97✔
1143
                                AngularZeroHandling = this.AngularZeroHandling,
97✔
1144
                        };
97✔
1145
                }
97✔
1146

1147
                internal override void AssignDocument(CadDocument doc)
1148
                {
3,336✔
1149
                        base.AssignDocument(doc);
3,336✔
1150

1151
                        this._style = CadObject.updateCollection(this.Style, doc.TextStyles);
3,336✔
1152

1153
                        this._lineType = CadObject.updateCollection(this.LineType, doc.LineTypes);
3,336✔
1154
                        this._lineTypeExt1 = CadObject.updateCollection(this.LineTypeExt1, doc.LineTypes);
3,336✔
1155
                        this._lineTypeExt2 = CadObject.updateCollection(this.LineTypeExt2, doc.LineTypes);
3,336✔
1156

1157
                        this._leaderArrow = CadObject.updateCollection(this.LeaderArrow, doc.BlockRecords);
3,336✔
1158
                        this._dimArrow1 = CadObject.updateCollection(this.DimArrow1, doc.BlockRecords);
3,336✔
1159
                        this._dimArrow2 = CadObject.updateCollection(this.DimArrow2, doc.BlockRecords);
3,336✔
1160
                        this._dimArrowBlock = CadObject.updateCollection(this.ArrowBlock, doc.BlockRecords);
3,336✔
1161

1162
                        doc.DimensionStyles.OnRemove += this.tableOnRemove;
3,336✔
1163
                        doc.LineTypes.OnRemove += this.tableOnRemove;
3,336✔
1164
                        doc.BlockRecords.OnRemove += this.tableOnRemove;
3,336✔
1165
                }
3,336✔
1166

1167
                internal override void UnassignDocument()
1168
                {
×
1169
                        this.Document.DimensionStyles.OnRemove -= this.tableOnRemove;
×
1170
                        this.Document.LineTypes.OnRemove -= this.tableOnRemove;
×
1171
                        this.Document.BlockRecords.OnRemove -= this.tableOnRemove;
×
1172

1173
                        base.UnassignDocument();
×
1174

1175
                        this.Style = (TextStyle)this.Style.Clone();
×
1176

1177
                        this.LineType = (LineType)(this.LineType?.Clone());
×
1178
                        this.LineTypeExt1 = (LineType)(this.LineTypeExt1?.Clone());
×
1179
                        this.LineTypeExt2 = (LineType)(this.LineTypeExt2?.Clone());
×
1180

1181
                        this.LeaderArrow = (BlockRecord)(this.LeaderArrow?.Clone());
×
1182
                        this.DimArrow1 = (BlockRecord)(this.DimArrow1?.Clone());
×
1183
                        this.DimArrow2 = (BlockRecord)(this.DimArrow2?.Clone());
×
1184
                        this.ArrowBlock = (BlockRecord)(this.ArrowBlock?.Clone());
×
1185
                }
×
1186

1187
                protected void tableOnRemove(object sender, CollectionChangedEventArgs e)
1188
                {
16✔
1189
                        if (e.Item.Equals(this.Style))
16!
1190
                        {
×
1191
                                this.Style = this.Document.TextStyles[TextStyle.DefaultName];
×
1192
                        }
×
1193

1194
                        if (e.Item is LineType ltype)
16✔
1195
                        {
7✔
1196
                                this.LineType = this.checkRemovedEntry(ltype, this.LineType);
7✔
1197
                                this.LineTypeExt1 = this.checkRemovedEntry(ltype, this.LineTypeExt1);
7✔
1198
                                this.LineTypeExt2 = this.checkRemovedEntry(ltype, this.LineTypeExt2);
7✔
1199
                        }
7✔
1200
                        else if (e.Item is BlockRecord blk)
9✔
1201
                        {
9✔
1202
                                this.LeaderArrow = this.checkRemovedEntry(blk, this.LeaderArrow);
9✔
1203
                                this.DimArrow1 = this.checkRemovedEntry(blk, this.DimArrow1);
9✔
1204
                                this.DimArrow2 = this.checkRemovedEntry(blk, this.DimArrow2);
9✔
1205
                                this.ArrowBlock = this.checkRemovedEntry(blk, this.ArrowBlock);
9✔
1206
                        }
9✔
1207
                }
16✔
1208

1209
                private T checkRemovedEntry<T>(T entry, T original)
1210
                {
57✔
1211
                        if (entry.Equals(original))
57✔
1212
                        {
7✔
1213
                                return default(T);
7✔
1214
                        }
1215
                        else
1216
                        {
50✔
1217
                                return original;
50✔
1218
                        }
1219
                }
57✔
1220

1221
                private string[] getDimStylePrefixAndSuffix(string text, char start, char end, out string prefix, out string suffix)
1222
                {
194✔
1223
                        int index = -1; // first occurrence of '<>' or '[]'
194✔
1224
                        for (int i = 0; i < text.Length; i++)
388✔
1225
                        {
194✔
1226
                                if (text[i] == start)
194!
1227
                                {
194✔
1228
                                        if (i + 1 < text.Length)
194!
1229
                                        {
194✔
1230
                                                if (text[i + 1] == end)
194!
1231
                                                {
194✔
1232
                                                        index = i;
194✔
1233
                                                        break;
194✔
1234
                                                }
1235
                                        }
×
1236
                                }
×
1237
                        }
×
1238

1239
                        if (index < 0)
194!
1240
                        {
×
1241
                                prefix = string.Empty;
×
1242
                                suffix = text;
×
1243
                        }
×
1244
                        else
1245
                        {
194✔
1246
                                prefix = text.Substring(0, index);
194✔
1247
                                suffix = text.Substring(index + 2, text.Length - (index + 2));
194✔
1248
                        }
194✔
1249

1250
                        return new[] { prefix, suffix };
194✔
1251
                }
194✔
1252
        }
1253
}
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

© 2025 Coveralls, Inc