Skip to content

Commit

Permalink
Added Types.AnalyticalElement.StructuralRole property.
Browse files Browse the repository at this point in the history
  • Loading branch information
kike-garbo committed Dec 17, 2024
1 parent 22116ad commit f0a785f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions src/RhinoInside.Revit.GH/Types/Structure/AnalyticalElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0a785f

Please sign in to comment.