From f0a785f23aa6b59570df39d258bd53720614e18a Mon Sep 17 00:00:00 2001 From: kike-garbo Date: Tue, 17 Dec 2024 14:53:50 +0100 Subject: [PATCH] Added `Types.AnalyticalElement.StructuralRole` property. --- .../Structure/AnalyticalElementIdentity.cs | 8 +++----- .../Types/Structure/AnalyticalElement.cs | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/RhinoInside.Revit.GH/Components/Structure/AnalyticalElementIdentity.cs b/src/RhinoInside.Revit.GH/Components/Structure/AnalyticalElementIdentity.cs index daee52f27..57816fd33 100644 --- a/src/RhinoInside.Revit.GH/Components/Structure/AnalyticalElementIdentity.cs +++ b/src/RhinoInside.Revit.GH/Components/Structure/AnalyticalElementIdentity.cs @@ -105,18 +105,16 @@ protected override void TrySolveInstance(IGH_DataAccess DA) if (!Params.GetData(DA, _AnalyticalElement_, out Types.AnalyticalElement element)) return; else Params.TrySetData(DA, _AnalyticalElement_, () => element); -#if REVIT_2023 if (!Params.TryGetData(DA, _StructuralRole_, out Types.AnalyticalStructuralRole structuralRole)) return; + if (!Params.TryGetData(DA, _AnalyzeAs_, out Types.AnalyzeAs analyzeAs)) return; if (structuralRole is object) { StartTransaction(element.Document); - element.Value.StructuralRole = structuralRole.Value; + element.StructuralRole = structuralRole; } - Params.TrySetData(DA, _StructuralRole_, () => element.Value.StructuralRole); -#endif + Params.TrySetData(DA, _StructuralRole_, () => element.StructuralRole); - if (!Params.TryGetData(DA, _AnalyzeAs_, out Types.AnalyzeAs analyzeAs)) return; if (analyzeAs is object) { StartTransaction(element.Document); diff --git a/src/RhinoInside.Revit.GH/Types/Structure/AnalyticalElement.cs b/src/RhinoInside.Revit.GH/Types/Structure/AnalyticalElement.cs index 9dc886955..d6d023f6f 100644 --- a/src/RhinoInside.Revit.GH/Types/Structure/AnalyticalElement.cs +++ b/src/RhinoInside.Revit.GH/Types/Structure/AnalyticalElement.cs @@ -63,6 +63,21 @@ protected override void DrawViewportWires(GH_PreviewWireArgs args) #endregion #region Properties + public AnalyticalStructuralRole StructuralRole + { +#if REVIT_2023 + get => Value is ARDB_Structure_AnalyticalElement element ? new AnalyticalStructuralRole(element.StructuralRole) : null; + set + { + if(Value is ARDB_Structure_AnalyticalElement element && element.StructuralRole != value.Value) + element.StructuralRole = value.Value; + } +#else + get => null; + set => throw new Exceptions.RuntimeErrorException($"The element does not allow setting the property '{StructuralRole}'."); +#endif + } + public AnalyzeAs AnalyzeAs { #if REVIT_2023