Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdf project branch #460

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion src/ACadSharp/CadDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions src/ACadSharp/Entities/Viewport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class Viewport : Entity
/// <summary>
/// Viewport ID.
/// </summary>
/// <remarks>
/// The first value for a PaperSpace will represent the paper image in the screen.
/// </remarks>
[DxfCodeValue(69)]
public short Id
{
Expand Down Expand Up @@ -348,6 +351,16 @@ public Scale Scale
}
}

public double ScaleFactor => 1 / (this.ViewHeight / this.Height);

public bool RepresentsPaper
{
get
{
return this.Id == PaperViewId;
}
}

private Scale _scale;

/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion src/ACadSharp/Objects/PlotSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public double DenominatorScale
public PlotPaperUnits PaperUnits { get; set; } = PlotPaperUnits.Milimeters;

/// <summary>
/// Plot paper units.
/// Plot paper rotation.
/// </summary>
[DxfCodeValue(73)]
public PlotRotation PaperRotation { get; set; }
Expand Down
23 changes: 23 additions & 0 deletions src/ACadSharp/Objects/Scale.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ACadSharp.Attributes;
using CSMath;

namespace ACadSharp.Objects
{
Expand All @@ -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 }; } }

/// <inheritdoc/>
public override ObjectType ObjectType { get { return ObjectType.UNLISTED; } }

Expand Down Expand Up @@ -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>(T value)
where T : IVector, new()
{
T result = new();

for (int i = 0; i < value.Dimension; i++)
{
result[i] = ApplyTo(value[i]);
}

return result;
}
}
}
10 changes: 5 additions & 5 deletions src/ACadSharp/Tables/BlockRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ public static BlockRecord PaperSpace
public new BlockTypeFlags Flags { get { return this.BlockEntity.Flags; } set { this.BlockEntity.Flags = value; } }

/// <summary>
/// Specifies whether the block can be exploded
/// Specifies whether the block can be exploded.
/// </summary>
[DxfCodeValue(DxfReferenceType.Optional, 280)]
public bool IsExplodable { get; set; }

/// <summary>
/// Specifies the scaling allowed for the block
/// Specifies the scaling allowed for the block.
/// </summary>
[DxfCodeValue(DxfReferenceType.Optional, 281)]
public bool CanScale { get; set; } = true;

/// <summary>
/// DXF: Binary data for bitmap preview
/// DXF: Binary data for bitmap preview.
/// </summary>
/// <remarks>
/// Optional
Expand All @@ -109,7 +109,7 @@ public static BlockRecord PaperSpace
public byte[] Preview { get; set; }

/// <summary>
/// Associated Layout
/// Associated Layout.
/// </summary>
[DxfCodeValue(DxfReferenceType.Handle, 340)]
public Layout Layout
Expand Down Expand Up @@ -144,7 +144,7 @@ public bool HasAttributes
}

/// <summary>
/// Viewports attached to this block
/// ViewPorts attached to this block
/// </summary>
public IEnumerable<Viewport> Viewports
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,116 +5,116 @@ public enum LineweightType : short
ByDIPs = -4,

/// <summary>
/// Default lineweight.
/// Default line weight.
/// </summary>
Default = -3,

/// <summary>
/// Lineweight defined by block.
/// Line weight defined by block.
/// </summary>
ByBlock = -2,

/// <summary>
/// Lineweight defined by layer.
/// Line weight defined by layer.
/// </summary>
ByLayer = -1,

/// <summary>
/// Lineweight value 0.00 mm (hairline).
/// Line weight value 0.00 mm (hairline).
/// </summary>
W0 = 0,

/// <summary>
/// Lineweight value 0.05 mm.
/// Line weight value 0.05 mm.
/// </summary>
W5 = 5,

/// <summary>
/// Lineweight value 0.09 mm.
/// Line weight value 0.09 mm.
/// </summary>
W9 = 9,
/// <summary>
/// Lineweight value 0.13 mm.
/// Line weight value 0.13 mm.
/// </summary>
W13 = 13,
/// <summary>
/// Lineweight value 0.15 mm.
/// Line weight value 0.15 mm.
/// </summary>
W15 = 15,
/// <summary>
/// Lineweight value 0.18 mm.
/// Line weight value 0.18 mm.
/// </summary>
W18 = 18,
/// <summary>
/// Lineweight value 0.20 mm.
/// Line weight value 0.20 mm.
/// </summary>
W20 = 20,
/// <summary>
/// Lineweight value 0.25 mm.
/// Line weight value 0.25 mm.
/// </summary>
W25 = 25,
/// <summary>
/// Lineweight value 0.30 mm.
/// Line weight value 0.30 mm.
/// </summary>
W30 = 30,
/// <summary>
/// Lineweight value 0.35 mm.
/// Line weight value 0.35 mm.
/// </summary>
W35 = 35,
/// <summary>
/// Lineweight value 0.40 mm.
/// Line weight value 0.40 mm.
/// </summary>
W40 = 40,
/// <summary>
/// Lineweight value 0.50 mm.
/// Line weight value 0.50 mm.
/// </summary>
W50 = 50,
/// <summary>
/// Lineweight value 0.53 mm.
/// Line weight value 0.53 mm.
/// </summary>
W53 = 53,
/// <summary>
/// Lineweight value 0.60 mm.
/// Line weight value 0.60 mm.
/// </summary>
W60 = 60,
/// <summary>
/// Lineweight value 0.70 mm.
/// Line weight value 0.70 mm.
/// </summary>
W70 = 70,
/// <summary>
/// Lineweight value 0.80 mm.
/// Line weight value 0.80 mm.
/// </summary>
W80 = 80,
/// <summary>
/// Lineweight value 0.90 mm.
/// Line weight value 0.90 mm.
/// </summary>
W90 = 90,
/// <summary>
/// Lineweight value 1.00 mm.
/// Line weight value 1.00 mm.
/// </summary>
W100 = 100,
/// <summary>
/// Lineweight value 1.06 mm.
/// Line weight value 1.06 mm.
/// </summary>
W106 = 106,
/// <summary>
/// Lineweight value 1.20 mm.
/// Line weight value 1.20 mm.
/// </summary>
W120 = 120,
/// <summary>
/// Lineweight value 1.40 mm.
/// Line weight value 1.40 mm.
/// </summary>
W140 = 140,
/// <summary>
/// Lineweight value 1.58 mm.
/// Line weight value 1.58 mm.
/// </summary>
W158 = 158,
/// <summary>
/// Lineweight value 2.00 mm.
/// Line weight value 2.00 mm.
/// </summary>
W200 = 200,
/// <summary>
/// Lineweight value 2.11 mm.
/// Line weight value 2.11 mm.
/// </summary>
W211 = 211
}
Expand Down
Loading