Skip to content

Commit

Permalink
unknown Object
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Aug 23, 2024
1 parent b9b5db1 commit 954a0b2
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/ACadSharp/Entities/UnknownEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
namespace ACadSharp.Entities
{
/// <summary>
/// Class that holds the basic information for an unknown entity
/// Class that holds the basic information for an unknown <see cref="Entity"/>.
/// </summary>
/// <remarks>
/// Unknown entities may appear in the <see cref="CadDocument"/> if the dwg file contains proxies or entities not yet supported by ACadSharp
/// Unknown entities may appear in the <see cref="CadDocument"/> if the cad file contains proxies or entities not yet supported by ACadSharp.
/// </remarks>
public class UnknownEntity : Entity
{
Expand Down Expand Up @@ -47,7 +47,7 @@ public override string SubclassMarker
}

/// <summary>
/// Dxf class linked to this entity
/// Dxf class linked to this entity.
/// </summary>
public DxfClass DxfClass { get; }

Expand All @@ -62,7 +62,7 @@ internal UnknownEntity(DxfClass dxfClass)
/// </remarks>
public override BoundingBox GetBoundingBox()
{
return default;
return BoundingBox.Null;
}
}
}
3 changes: 3 additions & 0 deletions src/ACadSharp/IO/DWG/DwgDocumentBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ACadSharp.Entities;
using ACadSharp.IO.Templates;
using ACadSharp.Objects;
using System.Collections.Generic;

namespace ACadSharp.IO.DWG
Expand All @@ -14,6 +15,8 @@ internal class DwgDocumentBuilder : CadDocumentBuilder

public List<UnknownEntity> UnknownEntities { get; } = new();

public List<UnknownNonGraphicalObject> UnknownNonGraphicalObjects { get; } = new();

public List<Entity> PaperSpaceEntities { get; } = new();

public List<Entity> ModelSpaceEntities { get; } = new();
Expand Down
25 changes: 20 additions & 5 deletions src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,6 @@ private CadTemplate readUnlistedType(short classNumber)
case "LWPOLYLINE":
template = this.readLWPolyline();
break;
case "MATERIAL":
break;
case "MESH":
template = this.readMesh();
break;
Expand All @@ -1019,9 +1017,9 @@ private CadTemplate readUnlistedType(short classNumber)
case "SORTENTSTABLE":
template = this.readSortentsTable();
break;
case "VISUALSTYLE":
template = this.readVisualStyle();
break;
//case "VISUALSTYLE":
// template = this.readVisualStyle();
// break;
case "WIPEOUT":
template = this.readCadImage(new Wipeout());
break;
Expand All @@ -1037,6 +1035,11 @@ private CadTemplate readUnlistedType(short classNumber)
template = this.readUnknownEntity(c);
this._builder.Notify($"Unlisted object with DXF name {c.DxfName} has been read as an UnknownEntity", NotificationType.Warning);
}
else if (template == null && !c.IsAnEntity)
{
template = this.readUnknownNonGraphicalObject(c);
this._builder.Notify($"Unlisted object with DXF name {c.DxfName} has been read as an UnknownNonGraphicalObject", NotificationType.Warning);
}

if (template == null)
{
Expand All @@ -1060,6 +1063,18 @@ private CadTemplate readUnknownEntity(DxfClass dxfClass)
return template;
}

private CadTemplate readUnknownNonGraphicalObject(DxfClass dxfClass)
{
UnknownNonGraphicalObject obj = new UnknownNonGraphicalObject(dxfClass);
CadUnknownNonGraphicalObjectTemplate template = new CadUnknownNonGraphicalObjectTemplate(obj);

this._builder.UnknownNonGraphicalObjects.Add(obj);

this.readCommonNonEntityData(template);

return template;
}

private CadTemplate readText()
{
TextEntity text = new TextEntity();
Expand Down
6 changes: 6 additions & 0 deletions src/ACadSharp/IO/Templates/CadUnknownEntityTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using ACadSharp.Entities;
using ACadSharp.Objects;

namespace ACadSharp.IO.Templates
{
internal class CadUnknownNonGraphicalObjectTemplate : CadNonGraphicalObjectTemplate
{
public CadUnknownNonGraphicalObjectTemplate(UnknownNonGraphicalObject obj) : base(obj) { }
}

internal class CadUnknownEntityTemplate : CadEntityTemplate
{
public CadUnknownEntityTemplate(UnknownEntity entity) : base(entity) { }
Expand Down
58 changes: 58 additions & 0 deletions src/ACadSharp/Objects/UnknownNonGraphicalObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using ACadSharp.Classes;

namespace ACadSharp.Objects
{
/// <summary>
/// Class that holds the basic information for an unknown <see cref="NonGraphicalObject"/>.
/// </summary>
/// <remarks>
/// Unknown entities may appear in the <see cref="CadDocument"/> if the cad file contains proxies or objects not yet supported by ACadSharp.
/// </remarks>
public class UnknownNonGraphicalObject : NonGraphicalObject
{
/// <inheritdoc/>
public override ObjectType ObjectType => ObjectType.UNDEFINED;

/// <inheritdoc/>
public override string ObjectName
{
get
{
if (this.DxfClass == null)
{
return "UNKNOWN";
}
else
{
return this.DxfClass.DxfName;
}
}
}

/// <inheritdoc/>
public override string SubclassMarker
{
get
{
if (this.DxfClass == null)
{
return DxfSubclassMarker.Entity;
}
else
{
return this.DxfClass.CppClassName;
}
}
}

/// <summary>
/// Dxf class linked to this entity.
/// </summary>
public DxfClass DxfClass { get; }

internal UnknownNonGraphicalObject(DxfClass dxfClass)
{
this.DxfClass = dxfClass;
}
}
}

0 comments on commit 954a0b2

Please sign in to comment.