From 8102b6ab135eb9c190bf02f1e7648650a155dc41 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Sun, 4 Dec 2022 16:12:18 -0700 Subject: [PATCH] improve entity default handle references --- src/IxMilia.Dwg/Objects/DwgEntity.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/IxMilia.Dwg/Objects/DwgEntity.cs b/src/IxMilia.Dwg/Objects/DwgEntity.cs index a40f88e..b5e4488 100644 --- a/src/IxMilia.Dwg/Objects/DwgEntity.cs +++ b/src/IxMilia.Dwg/Objects/DwgEntity.cs @@ -23,8 +23,8 @@ public abstract class DwgEntity : DwgObject internal DwgHandleReference LayerHandleReference { get; set; } public DwgLineType LineType { get; set; } internal DwgHandleReference LineTypeHandleReference { get; set; } - internal DwgHandleReference PreviousEntityHandle { get; set; } = new DwgHandleReference(DwgHandleReferenceCode.HandleMinus1, 0); - internal DwgHandleReference NextEntityHandle { get; set; } = new DwgHandleReference(DwgHandleReferenceCode.HandlePlus1, 0); + internal DwgHandleReference PreviousEntityHandle { get; set; } = new DwgHandleReference(DwgHandleReferenceCode.HardPointer, 0); + internal DwgHandleReference NextEntityHandle { get; set; } = new DwgHandleReference(DwgHandleReferenceCode.HardPointer, 0); internal virtual void OnBeforeEntityWrite(DwgVersionId version) { @@ -74,7 +74,12 @@ internal override void ReadCommonDataEnd(BitReader reader) LineTypeHandleReference = reader.Read_H(); } - if (!_noLinks) + if (_noLinks) + { + PreviousEntityHandle = new DwgHandleReference(DwgHandleReferenceCode.HandleMinus1, 0); + NextEntityHandle = new DwgHandleReference(DwgHandleReferenceCode.HandlePlus1, 0); + } + else { PreviousEntityHandle = reader.Read_H(); NextEntityHandle = reader.Read_H(); @@ -187,5 +192,13 @@ internal override void OnAfterObjectRead(BitReader reader, DwgObjectCache object OnAfterEntityRead(reader, objectCache, version); } + + internal void AssignSubentityReference(DwgHandle ownerHandle) + { + if (_entityMode == 0) + { + _subentityRef = ownerHandle.MakeHandleReference(DwgHandleReferenceCode.HardPointer); + } + } } }