diff --git a/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs b/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs index a78448ab..ac5c81df 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs @@ -2683,11 +2683,6 @@ private CadTemplate readDictionary() this.readCommonDictionary(template); - if (cadDictionary.Handle == this._builder.HeaderHandles.DICTIONARY_NAMED_OBJECTS) - { - - } - return template; } @@ -3654,7 +3649,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)) diff --git a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Common.cs b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Common.cs index 7935d2e7..a64cc717 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Common.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Common.cs @@ -349,7 +349,6 @@ private void writeReactorsAndDictionaryHandle(CadObject cadObject) //R2004+: if (this.R2004Plus) { - this._writer.WriteBit(noDictionary); if (!noDictionary) { diff --git a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs index 8a1e27fa..21d6104e 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs @@ -3,6 +3,7 @@ using CSUtilities.Converters; using CSUtilities.IO; using System; +using System.Collections.Generic; using System.IO; using System.Linq; @@ -153,7 +154,24 @@ private void writeDictionary(CadDictionary dictionary) { //Common: //Numitems L number of dictonary items - this._writer.WriteBitLong(dictionary.Count()); + List entries = new List(); + foreach (var item in dictionary) + { + if (item is XRecord && !this.WriteXRecords) + { + continue; + } + + if (item is UnknownNonGraphicalObject) + { + continue; + } + + entries.Add(item); + } + + //16 + this._writer.WriteBitLong(entries.Count); //R14 Only: if (this._version == ACadVersion.AC1014) @@ -171,16 +189,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); diff --git a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs index f7590efe..1270b39f 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs @@ -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);