diff --git a/src/ACadSharp/CadDocument.cs b/src/ACadSharp/CadDocument.cs
index 0b519372..58337539 100644
--- a/src/ACadSharp/CadDocument.cs
+++ b/src/ACadSharp/CadDocument.cs
@@ -249,7 +249,7 @@ public void CreateDefaults()
this.Header = new CadHeader(this);
this.SummaryInfo = new CadSummaryInfo();
- //The order of the elements is rellevant for the handles assignation
+ //The order of the elements is relevant for the handles assignation
//Initialize tables
this.BlockRecords ??= new BlockRecordsTable(this);
diff --git a/src/ACadSharp/Entities/Viewport.cs b/src/ACadSharp/Entities/Viewport.cs
index 5cdd6466..2c27ad3a 100644
--- a/src/ACadSharp/Entities/Viewport.cs
+++ b/src/ACadSharp/Entities/Viewport.cs
@@ -56,6 +56,9 @@ public class Viewport : Entity
///
/// Viewport ID.
///
+ ///
+ /// The first value for a PaperSpace will represent the paper image in the screen.
+ ///
[DxfCodeValue(69)]
public short Id
{
@@ -326,7 +329,7 @@ public double ViewWidth
//Soft pointer reference to viewport object (for layer VP property override)
///
- ///
+ /// Scale assigned for this viewport.
///
public Scale Scale
{
@@ -348,6 +351,28 @@ public Scale Scale
}
}
+ ///
+ /// Scale factor applied in this viewport.
+ ///
+ ///
+ /// Represents the scale applied to all the entities in the model when are visualized in the paper.
+ ///
+ public double ScaleFactor => 1 / (this.ViewHeight / this.Height);
+
+ ///
+ /// Flag that set for those viewports that represent the paper in the view.
+ ///
+ ///
+ /// A paper viewport is only for boundaries only, does not visualize anything.
+ ///
+ public bool RepresentsPaper
+ {
+ get
+ {
+ return this.Id == PaperViewId;
+ }
+ }
+
private Scale _scale;
///
@@ -368,7 +393,10 @@ public override BoundingBox GetBoundingBox()
return new BoundingBox(min, max);
}
- ///
+ ///
+ /// Gets the bounding box of this viewport in the model space.
+ ///
+ ///
public BoundingBox GetModelBoundingBox()
{
XYZ min = new XYZ(this.ViewCenter.X - this.ViewWidth / 2, this.ViewCenter.Y - this.ViewHeight / 2, 0);
diff --git a/src/ACadSharp/Objects/PlotSettings.cs b/src/ACadSharp/Objects/PlotSettings.cs
index f58a8c8e..171c647e 100644
--- a/src/ACadSharp/Objects/PlotSettings.cs
+++ b/src/ACadSharp/Objects/PlotSettings.cs
@@ -159,7 +159,7 @@ public double DenominatorScale
public PlotPaperUnits PaperUnits { get; set; } = PlotPaperUnits.Milimeters;
///
- /// Plot paper units.
+ /// Plot paper rotation.
///
[DxfCodeValue(73)]
public PlotRotation PaperRotation { get; set; }
diff --git a/src/ACadSharp/Objects/Scale.cs b/src/ACadSharp/Objects/Scale.cs
index b6701041..cf45894b 100644
--- a/src/ACadSharp/Objects/Scale.cs
+++ b/src/ACadSharp/Objects/Scale.cs
@@ -1,4 +1,5 @@
using ACadSharp.Attributes;
+using CSMath;
namespace ACadSharp.Objects
{
@@ -13,6 +14,8 @@ namespace ACadSharp.Objects
[DxfSubClass(DxfSubclassMarker.Scale)]
public class Scale : NonGraphicalObject
{
+ public static Scale Default { get { return new Scale { Name = "1:1", PaperUnits = 1.0, DrawingUnits = 1.0, IsUnitScale = true }; } }
+
///
public override ObjectType ObjectType { get { return ObjectType.UNLISTED; } }
@@ -56,10 +59,30 @@ public override string Name
[DxfCodeValue(290)]
public bool IsUnitScale { get; set; }
+ public double ScaleFactor => this.PaperUnits / this.DrawingUnits;
+
public Scale() { }
public Scale(string name) : base(name)
{
}
+
+ public double ApplyTo(double value)
+ {
+ return value * ScaleFactor;
+ }
+
+ public T ApplyTo(T value)
+ where T : IVector, new()
+ {
+ T result = new();
+
+ for (int i = 0; i < value.Dimension; i++)
+ {
+ result[i] = ApplyTo(value[i]);
+ }
+
+ return result;
+ }
}
}
diff --git a/src/ACadSharp/Tables/BlockRecord.cs b/src/ACadSharp/Tables/BlockRecord.cs
index 3fffa4a0..7e1eb0fd 100644
--- a/src/ACadSharp/Tables/BlockRecord.cs
+++ b/src/ACadSharp/Tables/BlockRecord.cs
@@ -88,19 +88,19 @@ public static BlockRecord PaperSpace
public new BlockTypeFlags Flags { get { return this.BlockEntity.Flags; } set { this.BlockEntity.Flags = value; } }
///
- /// Specifies whether the block can be exploded
+ /// Specifies whether the block can be exploded.
///
[DxfCodeValue(DxfReferenceType.Optional, 280)]
public bool IsExplodable { get; set; }
///
- /// Specifies the scaling allowed for the block
+ /// Specifies the scaling allowed for the block.
///
[DxfCodeValue(DxfReferenceType.Optional, 281)]
public bool CanScale { get; set; } = true;
///
- /// DXF: Binary data for bitmap preview
+ /// DXF: Binary data for bitmap preview.
///
///
/// Optional
@@ -109,7 +109,7 @@ public static BlockRecord PaperSpace
public byte[] Preview { get; set; }
///
- /// Associated Layout
+ /// Associated Layout.
///
[DxfCodeValue(DxfReferenceType.Handle, 340)]
public Layout Layout
@@ -144,7 +144,7 @@ public bool HasAttributes
}
///
- /// Viewports attached to this block
+ /// ViewPorts attached to this block
///
public IEnumerable Viewports
{
diff --git a/src/ACadSharp/Types/Lineweight.cs b/src/ACadSharp/Types/LineWeightType.cs
similarity index 59%
rename from src/ACadSharp/Types/Lineweight.cs
rename to src/ACadSharp/Types/LineWeightType.cs
index 6d589e79..938f8141 100644
--- a/src/ACadSharp/Types/Lineweight.cs
+++ b/src/ACadSharp/Types/LineWeightType.cs
@@ -5,116 +5,116 @@ public enum LineweightType : short
ByDIPs = -4,
///
- /// Default lineweight.
+ /// Default line weight.
///
Default = -3,
///
- /// Lineweight defined by block.
+ /// Line weight defined by block.
///
ByBlock = -2,
///
- /// Lineweight defined by layer.
+ /// Line weight defined by layer.
///
ByLayer = -1,
///
- /// Lineweight value 0.00 mm (hairline).
+ /// Line weight value 0.00 mm (hairline).
///
W0 = 0,
///
- /// Lineweight value 0.05 mm.
+ /// Line weight value 0.05 mm.
///
W5 = 5,
///
- /// Lineweight value 0.09 mm.
+ /// Line weight value 0.09 mm.
///
W9 = 9,
///
- /// Lineweight value 0.13 mm.
+ /// Line weight value 0.13 mm.
///
W13 = 13,
///
- /// Lineweight value 0.15 mm.
+ /// Line weight value 0.15 mm.
///
W15 = 15,
///
- /// Lineweight value 0.18 mm.
+ /// Line weight value 0.18 mm.
///
W18 = 18,
///
- /// Lineweight value 0.20 mm.
+ /// Line weight value 0.20 mm.
///
W20 = 20,
///
- /// Lineweight value 0.25 mm.
+ /// Line weight value 0.25 mm.
///
W25 = 25,
///
- /// Lineweight value 0.30 mm.
+ /// Line weight value 0.30 mm.
///
W30 = 30,
///
- /// Lineweight value 0.35 mm.
+ /// Line weight value 0.35 mm.
///
W35 = 35,
///
- /// Lineweight value 0.40 mm.
+ /// Line weight value 0.40 mm.
///
W40 = 40,
///
- /// Lineweight value 0.50 mm.
+ /// Line weight value 0.50 mm.
///
W50 = 50,
///
- /// Lineweight value 0.53 mm.
+ /// Line weight value 0.53 mm.
///
W53 = 53,
///
- /// Lineweight value 0.60 mm.
+ /// Line weight value 0.60 mm.
///
W60 = 60,
///
- /// Lineweight value 0.70 mm.
+ /// Line weight value 0.70 mm.
///
W70 = 70,
///
- /// Lineweight value 0.80 mm.
+ /// Line weight value 0.80 mm.
///
W80 = 80,
///
- /// Lineweight value 0.90 mm.
+ /// Line weight value 0.90 mm.
///
W90 = 90,
///
- /// Lineweight value 1.00 mm.
+ /// Line weight value 1.00 mm.
///
W100 = 100,
///
- /// Lineweight value 1.06 mm.
+ /// Line weight value 1.06 mm.
///
W106 = 106,
///
- /// Lineweight value 1.20 mm.
+ /// Line weight value 1.20 mm.
///
W120 = 120,
///
- /// Lineweight value 1.40 mm.
+ /// Line weight value 1.40 mm.
///
W140 = 140,
///
- /// Lineweight value 1.58 mm.
+ /// Line weight value 1.58 mm.
///
W158 = 158,
///
- /// Lineweight value 2.00 mm.
+ /// Line weight value 2.00 mm.
///
W200 = 200,
///
- /// Lineweight value 2.11 mm.
+ /// Line weight value 2.11 mm.
///
W211 = 211
}