Skip to content

Commit

Permalink
IsDynamic flag
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Jan 2, 2025
1 parent 104112d commit 3a6190d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ACadSharp.Tests/IO/DynamicBlockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public void DynamicBlocksTest(FileModel test)

BlockRecord blk = doc.BlockRecords["my-dynamic-block"];

Assert.True(blk.IsDynamic);

//Dictionary entry
EvaluationGraph eval = blk.XDictionary.GetEntry<EvaluationGraph>("ACAD_ENHANCEDBLOCK");

Expand Down
5 changes: 5 additions & 0 deletions src/ACadSharp/Objects/Evaluations/EvaluationGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace ACadSharp.Objects.Evaluations
[DxfSubClass(DxfSubclassMarker.EvalGraph)]
public partial class EvaluationGraph : NonGraphicalObject
{
/// <summary>
/// Dictionary entry name for the object <see cref="EvaluationGraph"/>
/// </summary>
public const string DictionaryEntryName = "ACAD_ENHANCEDBLOCK";

/// <inheritdoc/>
public override ObjectType ObjectType => ObjectType.UNLISTED;

Expand Down
34 changes: 34 additions & 0 deletions src/ACadSharp/Tables/BlockRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using ACadSharp.Entities;
using System.Linq;
using System.Collections.Generic;
using ACadSharp.Objects.Evaluations;

namespace ACadSharp.Tables
{
Expand Down Expand Up @@ -184,6 +185,39 @@ public SortEntitiesTable SortEntitiesTable
}
}

/// <summary>
/// Active flag if it has an <see cref="Objects.Evaluations.EvaluationGraph"/> attached to it with dynamic expressions.
/// </summary>
public bool IsDynamic
{
get
{
return this.EvaluationGraph != null;
}
}

/// <summary>
/// Gets the evaluation graph for this block if it has dynamic properties attached to it.
/// </summary>
public EvaluationGraph EvaluationGraph
{
get
{
if (this.XDictionary == null)
{
return null;
}
else if (this.XDictionary.TryGetEntry(EvaluationGraph.DictionaryEntryName, out EvaluationGraph table))
{
return table;
}
else
{
return null;
}
}
}

/// <summary>
/// Block entity for this record
/// </summary>
Expand Down

0 comments on commit 3a6190d

Please sign in to comment.