Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dynamic-blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Dec 16, 2024
2 parents 3288cd9 + 8bc0ca3 commit 4996c53
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 28 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/ACadSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.0.3</Version>
<Version>1.0.4</Version>
<PackageOutputPath>../nupkg</PackageOutputPath>
</PropertyGroup>

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
7 changes: 1 addition & 6 deletions src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2688,11 +2688,6 @@ private CadTemplate readDictionary()

this.readCommonDictionary(template);

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

}

return template;
}

Expand Down Expand Up @@ -3659,7 +3654,7 @@ private CadTemplate readBlockHeader()

//Common:
//Entry name TV 2
//Warning: names ended with a number are not readed in this method
//Warning: anonymous blocks do not write the full name, only *{type character}
string name = this._textReader.ReadVariableText();
if (name.Equals(BlockRecord.ModelSpaceName, System.StringComparison.CurrentCultureIgnoreCase) ||
name.Equals(BlockRecord.PaperSpaceName, System.StringComparison.CurrentCultureIgnoreCase))
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 @@ -350,7 +350,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
29 changes: 23 additions & 6 deletions src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using CSUtilities.Converters;
using CSUtilities.IO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

Expand Down Expand Up @@ -152,8 +153,24 @@ private void writeCadDictionaryWithDefault(CadDictionaryWithDefault dictionary)
private void writeDictionary(CadDictionary dictionary)
{
//Common:
//Numitems L number of dictonary items
this._writer.WriteBitLong(dictionary.Count());
//Numitems L number of dictionary items
List<NonGraphicalObject> entries = new List<NonGraphicalObject>();
foreach (var item in dictionary)
{
if (item is XRecord && !this.WriteXRecords)
{
continue;
}

if (item is UnknownNonGraphicalObject)
{
continue;
}

entries.Add(item);
}

this._writer.WriteBitLong(entries.Count);

//R14 Only:
if (this._version == ACadVersion.AC1014)
Expand All @@ -171,16 +188,16 @@ private void writeDictionary(CadDictionary dictionary)
}

//Common:
foreach (var item in dictionary)
foreach (var item in entries)
{
if (item is XRecord && !this.WriteXRecords)
{
return;
continue;
}

if (item is UnknownNonGraphicalObject)
{
return;
continue;
}

this._writer.WriteVariableText(item.Name);
Expand Down Expand Up @@ -730,4 +747,4 @@ private void writeXRecord(XRecord xrecord)

}
}
}
}
11 changes: 9 additions & 2 deletions src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,15 @@ private void writeBlockHeader(BlockRecord record)

//Common:
//Entry name TV 2
//Warning: names ended with a number are not readed in this method
this._writer.WriteVariableText(record.Name);
if (record.Flags.HasFlag(BlockTypeFlags.Anonymous))
{
//Warning: anonymous blocks do not write the full name, only *{type character}
this._writer.WriteVariableText(record.Name.Substring(0, 2));
}
else
{
this._writer.WriteVariableText(record.Name);
}

this.writeXrefDependantBit(record);

Expand Down
5 changes: 4 additions & 1 deletion src/ACadSharp/Objects/CadDictionaryWithDefault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ namespace ACadSharp.Objects
[DxfSubClass(DxfSubclassMarker.DictionaryWithDefault)]
public class CadDictionaryWithDefault : CadDictionary
{
/// <inheritdoc/>
public override ObjectType ObjectType { get { return ObjectType.UNLISTED; } }

public override string ObjectName => DxfFileToken.ObjectDictionary;
/// <inheritdoc/>
public override string ObjectName => DxfFileToken.ObjectDictionaryWithDefault;

/// <inheritdoc/>
public override string SubclassMarker => DxfSubclassMarker.DictionaryWithDefault;

/// <summary>
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 4996c53

Please sign in to comment.