Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ API between minor releases.
from. An element that placed that definition, or a later build from the block, could hold the same data twice, and which
elements did could differ between two reads of one file. The IFC export uses this data for triangle-set bodies and for
some base quantities.
- The rewrite of a Revit 2023 or later file into the 2022 layout keeps the fields it adds at the end of an object when
the object that follows has no Revit 2022 class and is cut out. Those fields were lost, which shifted the data after
them.
- A graphic style (`GStyleElem`) no longer gets a name from bytes that only look like one, from a string stored near its
id or from a linked type, and no `FamilyName` through such a link. The class stores no name and has no type, so its
`FamilyName` is now `null`, and so is its `Name` unless the element name table of the file holds one. String built-in
Expand Down
2 changes: 1 addition & 1 deletion src/RvtIO/Parsing/R22Transcoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ private sealed class Context(byte[] data, int pos, int end)
c.Cutting = true;
ReadObject(c, tag);
c.Cutting = false;
c.Edits.RemoveAll(e => e.Start > start || (e.Start == start && (_forReader || e.End > start)));
c.Edits.RemoveAll(e => e.Start > start || (e.Start == start && e.End > start));
c.Edits.Add(new(start, c.Pos, []));
for (int j = mark; j < c.Queue.Count; j++) c.Queue[j] = (c.Queue[j].Tag, true);
c.Slot = -1;
Expand Down
33 changes: 33 additions & 0 deletions tests/RvtIO.Tests/R22TranscoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,39 @@ public void Payload_RenumbersCutsInsertsAndLeavesOutUnknownObjects()
Assert.True(walk.Exact, walk.Error);
}

// the fields the 2022 class adds at the end of an object are inserted where the next object starts: cutting that one keeps them
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Payload_KeepsTheFieldsAddedAtTheEndOfAnObjectBeforeOneItCuts(bool forReader)
{
var target = Target();
target.Classes[target.Classes.FindIndex(c => c.Id == 10)] = new(10, "Store", 0, 1, [Field("m_value", 4), Field("m_later", 4)], []);
var block = Bytes(w =>
{
w.Write((ushort)5);
Owned(w, 3); // m_pStore
w.Write(1u); Owned(w, 4); // m_items: an Extra
w.Write(77L); w.Write(5); // m_id, m_added
w.Write(0u); // m_name, empty
w.Write(42); // Store
w.Write(9); // Extra
});
var expected = Bytes(w =>
{
w.Write((ushort)11);
Owned(w, 10);
w.Write(0u);
w.Write(77); w.Write(0); // m_id, m_gone
w.Write(0u);
w.Write(42); w.Write(0); // Store: m_value, m_later
});
var result = new R22Transcoder(Source(), target, 8, forReader: forReader).Payload(block, 0, block.Length);
Assert.Equal(expected, result);
var walk = new WideBlockWalker(target, (_, _) => null, []).Run(result!, 0, result!.Length, 11);
Assert.True(walk.Exact, walk.Error);
}

[Fact]
public void Payload_WritesFieldsInTheOrderOfThe2022Class()
{
Expand Down
Loading