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

Kike/1.x #1252

Merged
merged 4 commits 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
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
16 changes: 16 additions & 0 deletions src/RhinoInside.Revit.External/DB/AnalyticalStructuralRole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Autodesk.Revit.DB.Structure
{
#if !REVIT_2023
public enum AnalyticalStructuralRole
{
Unset = -1,
StructuralRoleBeam = 0,
StructuralRoleColumn = 1,
StructuralRoleMember = 3,
StructuralRoleGirder = 4,
StructuralRoleFloor = 5,
StructuralRoleWall = 6,
StructuralRolePanel = 7
}
#endif
}
5 changes: 3 additions & 2 deletions src/RhinoInside.Revit.GH/Components/Element/Parameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ internal static IGH_Goo AsGoo(this ARDB.Parameter parameter)
case ARDB.BuiltInParameter.VIEW_DETAIL_LEVEL: return new Types.ViewDetailLevel((ARDB.ViewDetailLevel) integer);
case ARDB.BuiltInParameter.VIEW_DISCIPLINE: return new Types.ViewDiscipline((ARDB.ViewDiscipline) integer);
case ARDB.BuiltInParameter.HOST_SSE_CURVED_EDGE_CONDITION_PARAM: return new Types.SlabShapeEditCurvedEdgeCondition((ERDB.SlabShapeEditCurvedEdgeCondition) integer);
#if REVIT_2023
case ARDB.BuiltInParameter.STRUCTURAL_ANALYZES_AS: return new Types.AnalyzeAs((ARDB.Structure.AnalyzeAs) integer);
#if REVIT_2023
case ARDB.BuiltInParameter.ANALYTICAL_ELEMENT_STRUCTURAL_ROLE: return new Types.AnalyticalStructuralRole((ARDB.Structure.AnalyticalStructuralRole) integer);
#endif
#endif
}

if (builtInParameter.IsColor())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@

namespace RhinoInside.Revit.GH.Components.Structure
{
[ComponentVersion(introduced: "1.27"), ComponentRevitAPIVersion(min: "2023.0")]
public class AnalyticalElementStructuralRole : TransactionalChainComponent
[ComponentVersion(introduced: "1.27")]
public class AnalyticalElementIdentity : TransactionalChainComponent
{
public override Guid ComponentGuid => new Guid("6844CF5E-8015-457E-AC7E-0E58C6B80A82");
#if REVIT_2023
public override GH_Exposure Exposure => GH_Exposure.tertiary;
#else
public override GH_Exposure Exposure => GH_Exposure.hidden;
#endif
public AnalyticalElementStructuralRole() : base

protected override string IconTag => "ID";

public AnalyticalElementIdentity() : base
(
name: "Element Structural Role",
nickname: "AE-Role",
description: "Given an analytical element from the Revit document, this component sets its structural role",
name: "Analytical Element Identity",
nickname: "AE-Identity",
description: "Analytical Element Data.",
category: "Revit",
subCategory: "Structure"
)
Expand All @@ -33,7 +32,6 @@ public AnalyticalElementStructuralRole() : base
NickName = "AE",
}
),
#if REVIT_2023
new ParamDefinition
(
new Parameters.Param_Enum<Types.AnalyticalStructuralRole>
Expand All @@ -42,7 +40,12 @@ public AnalyticalElementStructuralRole() : 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
(
Expand All @@ -54,7 +57,6 @@ public AnalyticalElementStructuralRole() : base
Optional = true,
}, ParamRelevance.Primary
),
#endif
};

protected override ParamDefinition[] Outputs => outputs;
Expand All @@ -68,15 +70,19 @@ public AnalyticalElementStructuralRole() : 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
(
Expand All @@ -87,7 +93,6 @@ public AnalyticalElementStructuralRole() : base
Description = "Structural analysis function to applied to the analytical element",
}, ParamRelevance.Primary
),
#endif
};

const string _AnalyticalElement_ = "Analytical Element";
Expand All @@ -102,23 +107,22 @@ protected override void TrySolveInstance(IGH_DataAccess DA)

#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;
}
Params.TrySetData(DA, _StructuralRole_, () => element.Value.StructuralRole);
#endif

if (!Params.TryGetData(DA, _AnalyzeAs_, out Types.AnalyzeAs analyzeAs)) return;
if (analyzeAs is object)
{
StartTransaction(element.Document);
element.Value.AnalyzeAs = analyzeAs.Value;
element.AnalyzeAs = analyzeAs;
}

Params.TrySetData(DA, _StructuralRole_, () => element.Value.StructuralRole);
Params.TrySetData(DA, _AnalyzeAs_, () => element.Value.AnalyzeAs);
#endif
Params.TrySetData(DA, _AnalyzeAs_, () => element.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 Down Expand Up @@ -777,5 +777,4 @@ public AnalyzeAs(ARDB.Structure.AnalyzeAs value) : base(value) { }
{ (int) ARDB.Structure.AnalyzeAs.GravityLateral, "Gravity lateral" },
};
}
#endif
}
21 changes: 21 additions & 0 deletions src/RhinoInside.Revit.GH/Types/Structure/AnalyticalElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ protected override void DrawViewportWires(GH_PreviewWireArgs args)
}
}
#endregion

#region Properties
public AnalyzeAs AnalyzeAs
{
#if REVIT_2023
get => Value is ARDB_Structure_AnalyticalElement element ? new AnalyzeAs(element.AnalyzeAs) : null;
set
{
if(Value is ARDB_Structure_AnalyticalElement element && element.AnalyzeAs != value.Value)
element.AnalyzeAs = value.Value;
}
#else
get => Value?.get_Parameter(ARDB.BuiltInParameter.STRUCTURAL_ANALYZES_AS) is ARDB.Parameter parameter ? new AnalyzeAs(parameter.AsEnum<ARDB.Structure.AnalyzeAs>()) : null;
set
{
if (Value?.get_Parameter(ARDB.BuiltInParameter.STRUCTURAL_ANALYZES_AS) is ARDB.Parameter parameter && parameter.AsEnum<ARDB.Structure.AnalyzeAs>() != value.Value)
parameter.Set(value.Value);
}
#endif
}
#endregion
}
}

Expand Down
Loading