Skip to content

Commit

Permalink
Added 'Query Analytical Element'
Browse files Browse the repository at this point in the history
  • Loading branch information
kike-garbo committed Dec 17, 2024
1 parent 6e31498 commit 77f1cea
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 11 deletions.
7 changes: 4 additions & 3 deletions docs/pages/_en/1.0/reference/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ group: Deployment & Configs
### WIP

- Added 'Reference Point' parameter.
- Added 'Add Analytical Element (Model)'
- Added 'Add Model Element (Analytical)'
- Added 'Query Analytical Element'
- Added 'Analytical Element Identity'
- Added 'Cluster Analytical Elements (Role)'
- Added 'Element Structural Role'
- Added 'Add Analytical Element'
- Added 'Add Model Element'
- Added 'Add Boundary Conditions (Point)'
- Added 'Add Boundary Conditions (Line)'
- Added 'Add Boundary Conditions (Area)'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public AnalyticalElementIdentity() : base
NickName = "AE",
}
),
#if REVIT_2023
new ParamDefinition
(
new Parameters.Param_Enum<Types.AnalyticalStructuralRole>
Expand All @@ -41,9 +40,13 @@ public AnalyticalElementIdentity() : base
NickName = "SR",
Description = "Structural Role to apply to the analytical element",
Optional = true,
}, ParamRelevance.Primary
),
},
#if REVIT_2023
ParamRelevance.Primary
#else
ParamRelevance.Occasional
#endif
),
new ParamDefinition
(
new Parameters.Param_Enum<Types.AnalyzeAs>
Expand All @@ -67,17 +70,20 @@ public AnalyticalElementIdentity() : base
NickName = "AE",
}
),
#if REVIT_2023
new ParamDefinition
(
new Parameters.Param_Enum<Types.AnalyticalStructuralRole>
{
Name = _StructuralRole_,
NickName = "SR",
Description = "Structural Role applied to the analytical element",
}, ParamRelevance.Primary
),
},
#if REVIT_2023
ParamRelevance.Primary
#else
ParamRelevance.Occasional
#endif
),
new ParamDefinition
(
new Parameters.Param_Enum<Types.AnalyzeAs>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using System.Linq;
using Grasshopper.Kernel;
using RhinoInside.Revit.External.DB.Extensions;
using ARDB = Autodesk.Revit.DB;

namespace RhinoInside.Revit.GH.Components.Walls
{
#if REVIT_2023
using ARDB_AnalyticalElement = ARDB.Structure.AnalyticalElement;
#else
using ARDB_AnalyticalElement = ARDB.Structure.AnalyticalModel;
#endif

[ComponentVersion(introduced: "1.27")]
public class QueryAnalyticalElements : ElementCollectorComponent
{
public override Guid ComponentGuid => new Guid("1D518EBF-D75D-4D9C-B962-9907352DF89A");
public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.obscure;

private ARDB.ElementFilter _ElementFilter = new ARDB.ElementClassFilter(typeof(ARDB_AnalyticalElement));
protected override ARDB.ElementFilter ElementFilter => _ElementFilter;

public QueryAnalyticalElements() : base
(
name: "Query Analytical Elements",
nickname: "A-Elements",
description: "Get all document analytical elements",
category: "Revit",
subCategory: "Structure"
)
{ }

protected override ParamDefinition[] Inputs => inputs;
static readonly ParamDefinition[] inputs =
{
new ParamDefinition(new Parameters.Document(), ParamRelevance.Occasional),
ParamDefinition.Create<Parameters.Param_Enum<Types.AnalyticalStructuralRole>>
(
name: "Structural Role",
nickname: "SR",
optional: true,
#if REVIT_2023
relevance: ParamRelevance.Primary
#else
relevance: ParamRelevance.Occasional
#endif
),
ParamDefinition.Create<Parameters.Param_Enum<Types.AnalyzeAs>>
(
name: "Analyze As",
nickname: "AS",
optional: true,
relevance: ParamRelevance.Primary
),
ParamDefinition.Create<Parameters.ElementFilter>
(
name: "Filter",
nickname: "F",
description: "Additional Filter.",
optional: true,
relevance: ParamRelevance.Primary
),
};

protected override ParamDefinition[] Outputs => outputs;
static readonly ParamDefinition[] outputs =
{
ParamDefinition.Create<Parameters.AnalyticalElement>("Analytical Elements", "AE", "Analytical elements list", GH_ParamAccess.list),
};

protected override void TrySolveInstance(IGH_DataAccess DA)
{
if (!Parameters.Document.GetDataOrDefault(this, DA, "Document", out var doc))
return;

if (!Params.TryGetData(DA, "Structural Role", out ARDB.Structure.AnalyticalStructuralRole? structuralRole)) return;
if (!Params.TryGetData(DA, "Analyze As", out ARDB.Structure.AnalyzeAs? analyzeAs)) return;
if (!Params.TryGetData(DA, "Filter", out ARDB.ElementFilter filter)) return;

using (var collector = new ARDB.FilteredElementCollector(doc))
{
var elementsCollector = collector.WherePasses(ElementFilter);

if (filter is object)
elementsCollector = elementsCollector.WherePasses(filter);

#if REVIT_2023
if (structuralRole is object)
elementsCollector = elementsCollector.WhereParameterEqualsTo(ARDB.BuiltInParameter.ANALYTICAL_ELEMENT_STRUCTURAL_ROLE, (int) structuralRole);
#endif
if (analyzeAs is object)
elementsCollector = elementsCollector.WhereParameterEqualsTo(ARDB.BuiltInParameter.STRUCTURAL_ANALYZES_AS, (int) analyzeAs);

Params.TrySetDataList(DA, "Analytical Elements", () => collector.Select(Types.AnalyticalElement.FromElement).TakeWhileIsNotEscapeKeyDown(this));
}
}
}
}
3 changes: 1 addition & 2 deletions src/RhinoInside.Revit.GH/Types/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ public class ModelUpdatesStatus : GH_Enum<ARDB.ModelUpdatesStatus>
{ (int) ARDB.ModelUpdatesStatus.UpdatedInCentral, "Updated In Central" },
};
}
#if REVIT_2023

[
ComponentVersion(introduced: "1.27"),
ComponentGuid("84CCF256-95C2-4D9B-BFCD-303567FDF89B"),
Expand All @@ -751,7 +751,6 @@ public AnalyticalStructuralRole(ARDB.Structure.AnalyticalStructuralRole value) :
{ (int) ARDB.Structure.AnalyticalStructuralRole.StructuralRolePanel, "Panel" },
};
}
#endif

[
ComponentVersion(introduced: "1.27"),
Expand Down

0 comments on commit 77f1cea

Please sign in to comment.