-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #502 from DomCR/xrecord-reference
Xrecord linked
- Loading branch information
Showing
5 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
using ACadSharp.Objects; | ||
using System; | ||
|
||
namespace ACadSharp.IO.Templates | ||
{ | ||
internal class CadXRecordTemplate : CadTemplate<XRecord> | ||
{ | ||
private readonly System.Collections.Generic.List<Tuple<int, ulong>> _entries = new(); | ||
|
||
public CadXRecordTemplate() : base(new XRecord()) { } | ||
|
||
public CadXRecordTemplate(XRecord cadObject) : base(cadObject) { } | ||
|
||
public void AddHandleReference(int code, ulong handle) | ||
{ | ||
_entries.Add(new Tuple<int, ulong>(code, handle)); | ||
} | ||
|
||
public override void Build(CadDocumentBuilder builder) | ||
{ | ||
base.Build(builder); | ||
|
||
foreach (var entry in _entries) | ||
{ | ||
if (builder.TryGetCadObject<CadObject>(entry.Item2, out CadObject obj)) | ||
{ | ||
this.CadObject.CreateEntry(entry.Item1, obj); | ||
} | ||
else | ||
{ | ||
builder.Notify($"XRecord reference not found {entry.Item1}|{entry.Item2}", NotificationType.Warning); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |