From eabf67bc848ffa4712f32832031ab566249094a2 Mon Sep 17 00:00:00 2001 From: DomCR Date: Mon, 3 Jul 2023 08:59:04 +0200 Subject: [PATCH] xrecord --- .../DxfObjectsSectionReader.cs | 31 +++++++++++++++++-- ACadSharp/IO/Templates/CadXRecordTemplate.cs | 2 ++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs b/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs index b3865990..bb0cebe7 100644 --- a/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs +++ b/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs @@ -62,8 +62,7 @@ private CadTemplate readObject() case DxfFileToken.ObjectSortEntsTable: return this.readSortentsTable(); case DxfFileToken.ObjectXRecord: - template = new CadXRecordTemplate(new XRecrod()); - break; + return this.readObjectCodes(new CadXRecordTemplate(), readXRecord); default: this._builder.Notify($"Object not implemented: {this._reader.ValueAsString}", NotificationType.NotImplemented); do @@ -159,6 +158,34 @@ private bool readLayout(CadTemplate template, DxfMap map) } } + private bool readXRecord(CadTemplate template, DxfMap map) + { + CadXRecordTemplate tmp = template as CadXRecordTemplate; + + //TODO: Finsih cadXrecordtemplate + + switch (this._reader.Code) + { + case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord: + this.readXRecordEntries(tmp.CadObject); + return true; + default: + return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]); + } + } + + private void readXRecordEntries(XRecrod recrod) + { + this._reader.ReadNext(); + + while (this._reader.DxfCode != DxfCode.Start) + { + recrod.Entries.Add(new XRecrod.Entry(this._reader.Code, this._reader.Value)); + + this._reader.ReadNext(); + } + } + private CadTemplate readDictionary() { CadDictionary cadDictionary = new CadDictionary(); diff --git a/ACadSharp/IO/Templates/CadXRecordTemplate.cs b/ACadSharp/IO/Templates/CadXRecordTemplate.cs index 23f010c3..90c1da7a 100644 --- a/ACadSharp/IO/Templates/CadXRecordTemplate.cs +++ b/ACadSharp/IO/Templates/CadXRecordTemplate.cs @@ -4,6 +4,8 @@ namespace ACadSharp.IO.Templates { internal class CadXRecordTemplate : CadTemplate { + public CadXRecordTemplate() : base(new XRecrod()) { } + public CadXRecordTemplate(XRecrod cadObject) : base(cadObject) { } public override bool CheckDxfCode(int dxfcode, object value)