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
5 changes: 5 additions & 0 deletions src/ACadSharp/Entities/ProxyEntity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ACadSharp.Attributes;
using ACadSharp.Classes;
using CSMath;
using System.IO;

namespace ACadSharp.Entities
{
Expand Down Expand Up @@ -64,6 +65,10 @@ public class ProxyEntity : Entity, IProxy
//An object ID(multiple entries can appear) (optional)

//94 0 (indicates end of object ID section)
/// <inheritdoc/>
/// <remarks>No <c>DxfCodeValue</c>: the DXF reader has no handler for code 311 on an entity.</remarks>
public Stream Data { get; set; }

/// <inheritdoc/>
public ACadVersion Version { get; set; }

Expand Down
20 changes: 16 additions & 4 deletions src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ internal partial class DwgObjectReader : DwgSectionIO
/// </summary>
private IDwgStreamReader _handlesReader;

private long _handleSectionOffset = -1;
Comment thread
WallanceLee marked this conversation as resolved.

private IDwgStreamReader _mergedReaders;

private long _objectInitialPos = 0;
Expand Down Expand Up @@ -234,7 +236,7 @@ private ObjectType getEntityType(long offset)
ulong handleSize = this._crcReader.ReadModularChar();

//Find the handles offset
ulong handleSectionOffset = (ulong)this._crcReader.PositionInBits() + sizeInBits - handleSize;
this._handleSectionOffset = (long)((ulong)this._crcReader.PositionInBits() + sizeInBits - handleSize);

//Create a handler section reader
this._objectReader = DwgStreamReaderBase.GetStreamHandler(this._version, HugeMemoryStream.Clone(this._memoryStream), this._reader.Encoding);
Expand All @@ -246,11 +248,11 @@ private ObjectType getEntityType(long offset)

//Create a handler section reader
this._handlesReader = DwgStreamReaderBase.GetStreamHandler(this._version, HugeMemoryStream.Clone(this._memoryStream), this._reader.Encoding);
this._handlesReader.SetPositionInBits((long)handleSectionOffset);
this._handlesReader.SetPositionInBits(this._handleSectionOffset);

//Create a text section reader
this._textReader = DwgStreamReaderBase.GetStreamHandler(this._version, HugeMemoryStream.Clone(this._memoryStream), this._reader.Encoding);
this._textReader.SetPositionByFlag((long)handleSectionOffset - 1);
this._textReader.SetPositionByFlag(this._handleSectionOffset - 1);

this._mergedReaders = new DwgMergedReader(this._objectReader, this._textReader, this._handlesReader);
}
Expand Down Expand Up @@ -1181,8 +1183,18 @@ private void readCommonProxyData(IProxy proxy)

//Common:
//Databits X databits, however many there are to the handles
//The retained data has no length of its own, it runs up to the handle section
if (this._handleSectionOffset > 0)
{
long dataBits = this._handleSectionOffset - this._objectReader.PositionInBits();
if (dataBits > 0)
{
int dataBytes = (int)((dataBits + 7L) / 8L);
byte[] data = this._objectReader.ReadBytes(dataBytes);

//TODO: Investigate how to read the data in proxies, it can contain data, strings and handles
proxy.Data = new MemoryStream(data, writable: false);
}
}
}

private CadTemplate readDbColor()
Expand Down
6 changes: 6 additions & 0 deletions src/ACadSharp/IProxy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ACadSharp.Classes;
using System.IO;

namespace ACadSharp;

Expand Down Expand Up @@ -29,5 +30,10 @@ public interface IProxy
/// </summary>
int ProxyClassId { get; }

/// <summary>
/// Gets or sets the retained data of the original object.
/// </summary>
Stream Data { get; set; }

ACadVersion Version { get; set; }
}
1 change: 1 addition & 0 deletions src/ACadSharp/Objects/ProxyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class ProxyObject : NonGraphicalObject, IProxy
[DxfCodeValue(310)]
public Stream BinaryData { get; set; }

/// <inheritdoc/>
[DxfCodeValue(311)]
public Stream Data { get; set; }

Expand Down
Loading