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 'Structural Component' parameter. #1251

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
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class AddAnalyticalElementByModel : AddAnalyticalElement
#endif
public AddAnalyticalElementByModel() : base
(
name: "Add Analytical Element (Model)",
name: "Add Analytical Element",
nickname: "ME-Analytical",
description: "Given a model element, it extracts its analytical element to the active Revit document",
description: "Given a model element, it adds an analytical element representation to the active Revit document",
category: "Revit",
subCategory: "Structure"
)
Expand Down Expand Up @@ -92,28 +92,39 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
var structuralRole = ARDB.Structure.AnalyticalStructuralRole.Unset;
switch (element)
{
case Types.StructuralMember member:

switch (member.Value.StructuralType)
case Types.StructuralInstance structural:
{
if (Types.StructuralInstance.IsStructuralFraming(structural.Value))
{
case ARDB.Structure.StructuralType.Beam:
structuralRole = ARDB.Structure.AnalyticalStructuralRole.StructuralRoleBeam;
typeId = member.Value.GetTypeId();
materialId = member.Value.StructuralMaterialId;
break;
case ARDB.Structure.StructuralType.Brace:
structuralRole = ARDB.Structure.AnalyticalStructuralRole.StructuralRoleGirder;
typeId = member.Value.GetTypeId();
materialId = member.Value.StructuralMaterialId;
break;
case ARDB.Structure.StructuralType.Column:
structuralRole = ARDB.Structure.AnalyticalStructuralRole.StructuralRoleColumn;
typeId = member.Value.GetTypeId();
materialId = member.Value.StructuralMaterialId;
break;
switch (structural)
{
case Types.StructuralBeam beam:
structuralRole = ARDB.Structure.AnalyticalStructuralRole.StructuralRoleBeam;
typeId = beam.Value.GetTypeId();
materialId = beam.Value.StructuralMaterialId;
break;

case Types.StructuralBrace brace:
structuralRole = ARDB.Structure.AnalyticalStructuralRole.StructuralRoleGirder;
typeId = brace.Value.GetTypeId();
materialId = brace.Value.StructuralMaterialId;
break;

case Types.StructuralColumn column:
structuralRole = ARDB.Structure.AnalyticalStructuralRole.StructuralRoleColumn;
typeId = column.Value.GetTypeId();
materialId = column.Value.StructuralMaterialId;
break;

case Types.StructuralFraming framing:
structuralRole = ARDB.Structure.AnalyticalStructuralRole.StructuralRoleMember;
typeId = framing.Value.GetTypeId();
materialId = framing.Value.StructuralMaterialId;
break;
}
}

break;
}
break;

case Types.Wall wall:
boundary = wall.TrimmedSurface;
Expand All @@ -140,13 +151,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
(
doc.Value, _AnalyticalElement_, analyticalMember =>
{
analyticalMember = Reconstruct
(
analyticalMember,
doc.Value,
element.Curve.ToCurve()
);

analyticalMember = Reconstruct(analyticalMember, doc.Value, element.Curve.ToCurve());
analyticalMember.StructuralRole = structuralRole;
analyticalMember.SectionTypeId = typeId;
analyticalMember.MaterialId = materialId;
Expand All @@ -160,13 +165,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
(
doc.Value, _AnalyticalElement_, analyticalMember =>
{
analyticalMember = Reconstruct
(
analyticalMember,
doc.Value,
element.Curve.ToCurve()
);

analyticalMember = Reconstruct(analyticalMember, doc.Value, element.Curve.ToCurve());
analyticalMember.StructuralRole = structuralRole;
analyticalMember.SectionTypeId = typeId;
analyticalMember.MaterialId = materialId;
Expand All @@ -180,13 +179,22 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
(
doc.Value, _AnalyticalElement_, analyticalMember =>
{
analyticalMember = Reconstruct
(
analyticalMember,
doc.Value,
element.Curve.ToCurve()
);
analyticalMember = Reconstruct(analyticalMember, doc.Value, element.Curve.ToCurve());
analyticalMember.StructuralRole = structuralRole;
analyticalMember.SectionTypeId = typeId;
analyticalMember.MaterialId = materialId;
DA.SetData(_AnalyticalElement_, analyticalMember);
return analyticalMember;
}
);
break;

case ARDB.Structure.AnalyticalStructuralRole.StructuralRoleMember:
ReconstructElement<ARDB_AnalyticalMember>
(
doc.Value, _AnalyticalElement_, analyticalMember =>
{
analyticalMember = Reconstruct(analyticalMember, doc.Value, element.Curve.ToCurve());
analyticalMember.StructuralRole = structuralRole;
analyticalMember.SectionTypeId = typeId;
analyticalMember.MaterialId = materialId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public AddFoundationIsolated() : base
{
new ParamDefinition
(
new Parameters.FamilyInstance()
new Parameters.StructuralInstance()
{
Name = _Foundation_,
NickName = _Foundation_.Substring(0, 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class AddModelElementByAnalytical : ElementTrackerComponent
#endif
public AddModelElementByAnalytical() : base
(
name: "Add Model Element (Analytical)",
name: "Add Model Element",
nickname: "AE-Model",
description: "Given an analytical element, it adds a model element to the active Revit document",
description: "Given an analytical element, it adds a model element representation to the active Revit document",
category: "Revit",
subCategory: "Structure"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public AddStructuralBeam() : base
{
new ParamDefinition
(
new Parameters.FamilyInstance()
new Parameters.StructuralInstance()
{
Name = _Beam_,
NickName = _Beam_.Substring(0, 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public AddStructuralBrace() : base
{
new ParamDefinition
(
new Parameters.FamilyInstance()
new Parameters.StructuralInstance()
{
Name = _Brace,
NickName = _Brace.Substring(0, 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public AddStructuralColumn() : base
{
new ParamDefinition
(
new Parameters.FamilyInstance()
new Parameters.StructuralInstance()
{
Name = _Column_,
NickName = _Column_.Substring(0, 1),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using Grasshopper.Kernel;
using ARDB = Autodesk.Revit.DB;

namespace RhinoInside.Revit.GH.Parameters
{
[ComponentVersion(introduced: "1.27")]
public class StructuralInstance : GraphicalElement<Types.IGH_StructuralInstance, ARDB.FamilyInstance>
{
public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure;
public override Guid ComponentGuid => new Guid("54C68928-F012-42B0-94DC-DC9FC00FAE31");
protected override string IconTag => "SC";

public StructuralInstance() : base("Structural Component", "Structural Component", "Contains a collection of Revit Structural Component elements", "Params", "Revit Elements") { }

public override bool AllowElement(ARDB.Element elem) => base.AllowElement(elem) && Types.StructuralInstance.IsValidElement(elem);
}
}
4 changes: 2 additions & 2 deletions src/RhinoInside.Revit.GH/Types/GraphicalElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ static class ElementJoins
return ARDB.WallUtils.IsWallJoinAllowedAtEnd(wall, end);

case ARDB.FamilyInstance instance:
if (StructuralMember.IsStructuralFraming(instance))
if (StructuralInstance.IsStructuralFraming(instance))
return ARDB.Structure.StructuralFramingUtils.IsJoinAllowedAtEnd(instance, end);

break;
Expand All @@ -808,7 +808,7 @@ static void AllowJoinAtEnd(ARDB.Element element, int end, bool? allow)
return;

case ARDB.FamilyInstance instance:
if (StructuralMember.IsStructuralFraming(instance))
if (StructuralInstance.IsStructuralFraming(instance))
{
if (allow.Value) ARDB.Structure.StructuralFramingUtils.AllowJoinAtEnd(instance, end);
else ARDB.Structure.StructuralFramingUtils.DisallowJoinAtEnd(instance, end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ namespace RhinoInside.Revit.GH.Types
using Convert.Geometry;
using External.DB.Extensions;

[Kernel.Attributes.Name("Structural Member")]
public class StructuralMember : FamilyInstance
[Kernel.Attributes.Name("Structural Component")]
public interface IGH_StructuralInstance : IGH_FamilyInstance { }

[Kernel.Attributes.Name("Structural Component")]
public class StructuralInstance : FamilyInstance, IGH_StructuralInstance
{
protected override bool SetValue(ARDB.Element element) => IsValidElement(element) && base.SetValue(element);
public static new bool IsValidElement(ARDB.Element element)
{
return ((element as ARDB.FamilyInstance)?.StructuralType) != ARDB.Structure.StructuralType.NonStructural;
}

public StructuralMember() { }
public StructuralMember(ARDB.FamilyInstance value) : base(value) { }
public StructuralInstance() { }
public StructuralInstance(ARDB.FamilyInstance value) : base(value) { }

#region Joins
public static bool IsStructuralFraming(ARDB.FamilyInstance frame) =>
Expand Down Expand Up @@ -109,7 +112,7 @@ public bool? IsJoinAllowedAtEnd
}

[Kernel.Attributes.Name("Structural Beam")]
public class StructuralBeam : StructuralMember
public class StructuralBeam : StructuralInstance
{
protected override bool SetValue(ARDB.Element element) => IsValidElement(element) && base.SetValue(element);
public static new bool IsValidElement(ARDB.Element element)
Expand Down Expand Up @@ -156,7 +159,7 @@ public override void SetCurve(Curve curve, bool keepJoins = false)
}

[Kernel.Attributes.Name("Structural Brace")]
public class StructuralBrace : StructuralMember
public class StructuralBrace : StructuralInstance
{
protected override bool SetValue(ARDB.Element element) => IsValidElement(element) && base.SetValue(element);
public static new bool IsValidElement(ARDB.Element element)
Expand All @@ -169,7 +172,7 @@ public StructuralBrace(ARDB.FamilyInstance value) : base(value) { }
}

[Kernel.Attributes.Name("Structural Column")]
public class StructuralColumn : StructuralMember
public class StructuralColumn : StructuralInstance
{
protected override bool SetValue(ARDB.Element element) => IsValidElement(element) && base.SetValue(element);
public static new bool IsValidElement(ARDB.Element element)
Expand Down Expand Up @@ -217,7 +220,7 @@ public override void SetCurve(Curve curve, bool keepJoins = false)
}

[Kernel.Attributes.Name("Structural Foundation")]
public class StructuralFooting : StructuralMember
public class StructuralFooting : StructuralInstance
{
protected override bool SetValue(ARDB.Element element) => IsValidElement(element) && base.SetValue(element);
public static new bool IsValidElement(ARDB.Element element)
Expand All @@ -230,7 +233,7 @@ public StructuralFooting(ARDB.FamilyInstance value) : base(value) { }
}

[Kernel.Attributes.Name("Structural Framing")]
public class StructuralFraming : StructuralMember
public class StructuralFraming : StructuralInstance
{
protected override bool SetValue(ARDB.Element element) => IsValidElement(element) && base.SetValue(element);
public static new bool IsValidElement(ARDB.Element element)
Expand Down
Loading