Skip to content

Commit 804ad6b

Browse files
authored
Merge pull request #938 from cpetry/master
Fixes #937 - Added LinearScaleFactor multiplication
2 parents 01ac853 + 19458b6 commit 804ad6b

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/ACadSharp.Tests/Tables/DimensionStyleTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ static DimensionStyleTests()
8989
new DimensionAligned(XYZ.Zero, new XYZ(10, 0, 0)),
9090
"10"
9191
},
92+
{
93+
new DimensionStyle {
94+
LinearUnitFormat = LinearUnitFormat.Decimal,
95+
LinearScaleFactor = 10
96+
},
97+
new DimensionLinear {
98+
FirstPoint = XYZ.Zero,
99+
SecondPoint = new XYZ(10, 0, 0)
100+
},
101+
"100"
102+
},
92103
{
93104
new DimensionStyle {
94105
LinearUnitFormat = LinearUnitFormat.Decimal

src/ACadSharp/Entities/Dimension.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,25 +366,26 @@ public string GetMeasurementText(DimensionStyle style)
366366
}
367367
else
368368
{
369+
var scaledValue = value * style.LinearScaleFactor;
369370
switch (style.LinearUnitFormat)
370371
{
371372
case LinearUnitFormat.Scientific:
372-
text = unitFormat.ToScientific(value);
373+
text = unitFormat.ToScientific(scaledValue);
373374
break;
374375
case LinearUnitFormat.Engineering:
375-
text = unitFormat.ToEngineering(value);
376+
text = unitFormat.ToEngineering(scaledValue);
376377
break;
377378
case LinearUnitFormat.Architectural:
378-
text = unitFormat.ToArchitectural(value);
379+
text = unitFormat.ToArchitectural(scaledValue);
379380
break;
380381
case LinearUnitFormat.Fractional:
381-
text = unitFormat.ToFractional(value);
382+
text = unitFormat.ToFractional(scaledValue);
382383
break;
383384
case LinearUnitFormat.None:
384385
case LinearUnitFormat.Decimal:
385386
case LinearUnitFormat.WindowsDesktop:
386387
default:
387-
text = unitFormat.ToDecimal(value);
388+
text = unitFormat.ToDecimal(scaledValue);
388389
break;
389390
}
390391
}

0 commit comments

Comments
 (0)