Skip to content

Commit

Permalink
Merge pull request #509 from DomCR/issue-501_dwgWriter-dimensions
Browse files Browse the repository at this point in the history
issue 501 dimension not showing
  • Loading branch information
DomCR authored Dec 16, 2024
2 parents bd749b5 + 0c2f79b commit b6fa405
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/ACadSharp.Tests/IO/LocalSampleTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using ACadSharp.Entities;
using ACadSharp.IO;
using ACadSharp.Tables;
using ACadSharp.Tests.TestModels;
using CSMath;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand Down
18 changes: 15 additions & 3 deletions src/ACadSharp.Tests/IO/WriterSingleObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ public class SingleCaseGenerator : IXunitSerializable

public CadDocument Document { get; private set; } = new CadDocument();

public SingleCaseGenerator() { }
public SingleCaseGenerator()
{
this.Document.Header.ShowModelSpace = true;
}

public SingleCaseGenerator(string name)
public SingleCaseGenerator(string name) : this()
{
this.Name = name;
this.Document.Header.ShowModelSpace = true;
}

public override string ToString()
Expand Down Expand Up @@ -410,6 +412,15 @@ public void AddCustomScale()
this.Document.Scales.Add(new Scale("Hello"));
}

public void Dimensions()
{
DimensionAligned dim = new DimensionAligned();

dim.SecondPoint = new XYZ(10);

this.Document.Entities.Add(dim);
}

public void AddCustomBookColor()
{
//var color = new BookColor("RAL CLASSIC$RAL 1006");
Expand Down Expand Up @@ -513,6 +524,7 @@ static WriterSingleObjectTests()
Data.Add(new(nameof(SingleCaseGenerator.AddBlockWithAttributes)));
Data.Add(new(nameof(SingleCaseGenerator.AddCustomScale)));
Data.Add(new(nameof(SingleCaseGenerator.AddCustomBookColor)));
Data.Add(new(nameof(SingleCaseGenerator.Dimensions)));
}

protected string getPath(string name, string ext, ACadVersion version)
Expand Down
2 changes: 1 addition & 1 deletion src/ACadSharp/Header/CadHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2967,7 +2967,7 @@ public static Dictionary<string, CadSystemVariable> GetHeaderMap()
}

/// <summary>
/// Set a valueo of a system variable by name
/// Set a value of a system variable by name
/// </summary>
/// <param name="systemvar">name of the system var</param>
/// <param name="values">parameters for the constructor of the value</param>
Expand Down
2 changes: 2 additions & 0 deletions src/ACadSharp/IO/DWG/DwgReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ public override CadHeader ReadHeader()
if (this._builder != null)
this._builder.HeaderHandles = headerHandles;

header.Document = this._document;

return header;
}

Expand Down
5 changes: 0 additions & 5 deletions src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2683,11 +2683,6 @@ private CadTemplate readDictionary()

this.readCommonDictionary(template);

if (cadDictionary.Handle == this._builder.HeaderHandles.DICTIONARY_NAMED_OBJECTS)
{

}

return template;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ACadSharp/IO/DWG/DwgStreamWriters/DwgHeaderWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Write()
//R2013+:
if (this.R2013Plus)
{
//BLL : Variabele REQUIREDVERSIONS, default value 0, read only.
//BLL : Variable REQUIREDVERSIONS, default value 0, read only.
this._writer.WriteBitLongLong(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ private void writeReactorsAndDictionaryHandle(CadObject cadObject)
//R2004+:
if (this.R2004Plus)
{

this._writer.WriteBit(noDictionary);
if (!noDictionary)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ private void writeCommonDimensionData(Dimension dimension)
//H 3 DIMSTYLE(hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, dimension.Style);
//H 2 anonymous BLOCK(hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, dimension.Block);
//TODO: fix annotative dimensions
//this._writer.HandleReference(DwgReferenceType.HardPointer, dimension.Block);
this._writer.HandleReference(DwgReferenceType.HardPointer, null);
}

private void writeDimensionLinear(DimensionLinear dimension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ private void writeDictionary(CadDictionary dictionary)
entries.Add(item);
}

//16
this._writer.WriteBitLong(entries.Count);

//R14 Only:
Expand Down
8 changes: 3 additions & 5 deletions src/ACadSharp/Tables/VPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace ACadSharp.Tables
{
//TODO: Implement UCS for VPORT

/// <summary>
/// Represents a <see cref="VPort"/> table entry
/// </summary>
Expand Down Expand Up @@ -144,13 +142,13 @@ public XYZ Direction
/// Render mode
/// </summary>
[DxfCodeValue(281)]
public RenderMode RenderMode { get; set; }
public RenderMode RenderMode { get; set; } = RenderMode.Optimized2D;

/// <summary>
/// View mode(see VIEWMODE system variable)
/// </summary>
[DxfCodeValue(71)]
public ViewModeType ViewMode { get; set; }
public ViewModeType ViewMode { get; set; } = ViewModeType.FrontClippingZ;

/// <summary>
/// UCSICON setting
Expand Down Expand Up @@ -223,7 +221,7 @@ public XYZ Direction
/// Orthographic type of UCS
/// </summary>
[DxfCodeValue(79)]
public OrthographicType OrthographicType { get; set; }
public OrthographicType OrthographicType { get; set; } = OrthographicType.None;

/// <summary>
/// Elevation
Expand Down

0 comments on commit b6fa405

Please sign in to comment.