Skip to content

Commit

Permalink
assign linetype owner handles
Browse files Browse the repository at this point in the history
  • Loading branch information
brettfo committed Dec 4, 2022
1 parent a634063 commit 1f24d1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/IxMilia.Dwg/DwgDrawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public void Save(Stream stream)

var objectMap = new DwgObjectMap();
AssignHandles(objectMap);
AssignOwnershipHandles();

// write the file header; this will be re-written again once the pointers have been calculated
var writer = new BitWriter(stream);
Expand Down Expand Up @@ -355,6 +356,14 @@ private void AssignHandles(DwgObjectMap objectMap)
objectMap.SetNextAvailableHandle(Variables);
}

private void AssignOwnershipHandles()
{
foreach (var lt in LineTypes.Values)
{
lt.LineTypeControlHandleReference = LineTypes.Handle.MakeHandleReference(DwgHandleReferenceCode.HardPointer);
}
}

private void EnsureObjectMemberships()
{
EnsureCollectionContains(BlockHeaders, nameof(BlockHeaders),
Expand Down
8 changes: 0 additions & 8 deletions src/IxMilia.Dwg/Objects/DwgLineType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ public DwgLineType(string name)
Name = name;
}

internal override void OnAfterObjectRead(BitReader reader, DwgObjectCache objectCache, DwgVersionId version)
{
if (!LineTypeControlHandleReference.IsEmpty && LineTypeControlHandleReference.Code != DwgHandleReferenceCode.HardPointer)
{
throw new DwgReadException("Incorrect line type control object parent handle code.");
}
}

internal override void ParseSpecific(BitReader reader, int objectBitOffsetStart, DwgVersionId version)
{
Name = reader.Read_T();
Expand Down

0 comments on commit 1f24d1b

Please sign in to comment.