From 3a6190d0d8f2cca5b2001449c113ab4da1d4d169 Mon Sep 17 00:00:00 2001 From: DomCR Date: Thu, 2 Jan 2025 21:49:24 +0100 Subject: [PATCH] IsDynamic flag --- src/ACadSharp.Tests/IO/DynamicBlockTests.cs | 2 ++ .../Objects/Evaluations/EvaluationGraph.cs | 5 +++ src/ACadSharp/Tables/BlockRecord.cs | 34 +++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/ACadSharp.Tests/IO/DynamicBlockTests.cs b/src/ACadSharp.Tests/IO/DynamicBlockTests.cs index b673b797..983cbfd3 100644 --- a/src/ACadSharp.Tests/IO/DynamicBlockTests.cs +++ b/src/ACadSharp.Tests/IO/DynamicBlockTests.cs @@ -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("ACAD_ENHANCEDBLOCK"); diff --git a/src/ACadSharp/Objects/Evaluations/EvaluationGraph.cs b/src/ACadSharp/Objects/Evaluations/EvaluationGraph.cs index f9a10bae..a43a5c82 100644 --- a/src/ACadSharp/Objects/Evaluations/EvaluationGraph.cs +++ b/src/ACadSharp/Objects/Evaluations/EvaluationGraph.cs @@ -11,6 +11,11 @@ namespace ACadSharp.Objects.Evaluations [DxfSubClass(DxfSubclassMarker.EvalGraph)] public partial class EvaluationGraph : NonGraphicalObject { + /// + /// Dictionary entry name for the object + /// + public const string DictionaryEntryName = "ACAD_ENHANCEDBLOCK"; + /// public override ObjectType ObjectType => ObjectType.UNLISTED; diff --git a/src/ACadSharp/Tables/BlockRecord.cs b/src/ACadSharp/Tables/BlockRecord.cs index 7e1eb0fd..0c41d0f9 100644 --- a/src/ACadSharp/Tables/BlockRecord.cs +++ b/src/ACadSharp/Tables/BlockRecord.cs @@ -5,6 +5,7 @@ using ACadSharp.Entities; using System.Linq; using System.Collections.Generic; +using ACadSharp.Objects.Evaluations; namespace ACadSharp.Tables { @@ -184,6 +185,39 @@ public SortEntitiesTable SortEntitiesTable } } + /// + /// Active flag if it has an attached to it with dynamic expressions. + /// + public bool IsDynamic + { + get + { + return this.EvaluationGraph != null; + } + } + + /// + /// Gets the evaluation graph for this block if it has dynamic properties attached to it. + /// + 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; + } + } + } + /// /// Block entity for this record ///