Skip to content

Commit

Permalink
insert fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Feb 27, 2025
1 parent 8f0092b commit 26fa0e6
Showing 1 changed file with 6 additions and 74 deletions.
80 changes: 6 additions & 74 deletions src/ACadSharp/Entities/Insert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,50 +47,23 @@ public class Insert : Entity
/// True if the insert has attribute entities in it
/// </summary>
[DxfCodeValue(DxfReferenceType.Ignored, 66)]
public bool HasAttributes { get { return this.Attributes.Any(); } }
public bool HasAttributes
{ get { return this.Attributes.Any(); } }

/// <inheritdoc/>
public override bool HasDynamicSubclass => true;
[DxfCodeValue(DxfReferenceType.Ignored, 66)]
public bool HasAttributes
{ get { return this.Attributes.Any(); } }

/// <summary>
/// A 3D WCS coordinate representing the insertion or origin point.
/// </summary>
[DxfCodeValue(10, 20, 30)]
public XYZ InsertPoint { get; set; } = XYZ.Zero;

/// <summary>
/// Flag is true for multiple insertion of the same block.
/// Specifies the three-dimensional normal unit vector for the object.
/// </summary>
[DxfCodeValue(210, 220, 230)]
public XYZ Normal { get; set; } = XYZ.AxisZ;

/// <inheritdoc/>
public override string ObjectName => DxfFileToken.EntityInsert;

/// <inheritdoc/>
public override ObjectType ObjectType
{
get
{
if (this.RowCount > 1 || this.ColumnCount > 1)
{
return ObjectType.MINSERT;
}
else
{
return ObjectType.INSERT;
}
}
}

/// <summary>
/// Specifies the rotation angle for the object.
/// </summary>
public bool IsMultiple { get { return this.RowCount > 1 || this.ColumnCount > 1; } }
public bool IsMultiple
{ get { return this.RowCount > 1 || this.ColumnCount > 1; } }

/// <summary>
/// Specifies the three-dimensional normal unit vector for the object.
Expand All @@ -106,7 +79,7 @@ public override ObjectType ObjectType
{
get
{
if (this.IsMultiple)
if (this.RowCount > 1 || this.ColumnCount > 1)
{
return ObjectType.MINSERT;
}
Expand Down Expand Up @@ -138,9 +111,6 @@ public override ObjectType ObjectType
[DxfCodeValue(DxfReferenceType.Optional, 45)]
public double RowSpacing { get; set; } = 0;

/// <inheritdoc/>
public override string SubclassMarker => DxfSubclassMarker.Insert;

/// <inheritdoc/>
public override string SubclassMarker => this.IsMultiple ? DxfSubclassMarker.MInsert : DxfSubclassMarker.Insert;

Expand Down Expand Up @@ -183,48 +153,11 @@ public Insert(BlockRecord block) : this()
this.UpdateAttributes();
}

internal Insert() : base()
internal Insert() : base()
{
this.Attributes = new SeqendCollection<AttributeEntity>(this);
}

/// <inheritdoc/>
public override CadObject Clone()
{
Insert clone = (Insert)base.Clone();

clone.Block = (BlockRecord)this.Block?.Clone();

clone.Attributes = new SeqendCollection<AttributeEntity>(clone);
foreach (var att in this.Attributes)
{
clone.Attributes.Add((AttributeEntity)att.Clone());
}

return clone;
}

/// <inheritdoc/>
public override BoundingBox GetBoundingBox()
{
BoundingBox box = this.Block.BlockEntity.GetBoundingBox();

var scale = new XYZ(this.XScale, this.YScale, this.ZScale);
var min = box.Min * scale + this.InsertPoint;
var max = box.Max * scale + this.InsertPoint;

return new BoundingBox(min, max);
}

/// <summary>
/// Updates all attribute definitions contained in the block reference as <see cref="AttributeDefinition"/> entitites in the insert
/// </summary>
public void UpdateAttributes()
{
this.Attributes = new SeqendCollection<AttributeEntity>(this);
}

/// <inheritdoc/>
public override void ApplyTransform(Transform transform)
{
Expand Down Expand Up @@ -308,8 +241,7 @@ public void UpdateAttributes()
{
this.Attributes.Remove(att);
}
this.Attributes.Add(att);
}
this.Attributes.Add(att);
}
}

Expand Down

0 comments on commit 26fa0e6

Please sign in to comment.