Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Types.AnalyticalElement.StructuralRole property. #1253

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading