From 333bb10591f75fb7d3b6341f767b3df6cdb46aa0 Mon Sep 17 00:00:00 2001
From: Pedro Cortes
Date: Thu, 9 Jan 2025 13:56:12 +0100
Subject: [PATCH] Added specific components for Boundary Conditions
---
docs/pages/_en/1.0/reference/release-notes.md | 12 +-
.../DB/BoundaryConditionsState.cs | 10 -
.../Components/Element/Parameters.cs | 1 -
.../Structure/AddAnalyticalElement-Model.cs | 223 ++++++++++--------
.../Structure/AddAnalyticalMember.cs | 58 -----
.../Structure/AddBoundaryConditions-Area.cs | 3 +-
.../Structure/AddBoundaryConditions-Line.cs | 3 +-
.../Structure/AddBoundaryConditions-Point.cs | 3 +-
.../Types/Element.Activator.cs | 12 +-
src/RhinoInside.Revit.GH/Types/Enums.cs | 19 --
.../Types/Structure/BoundaryConditions.cs | 197 +++++++---------
11 files changed, 221 insertions(+), 320 deletions(-)
delete mode 100644 src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs
diff --git a/docs/pages/_en/1.0/reference/release-notes.md b/docs/pages/_en/1.0/reference/release-notes.md
index 5b5848d1f..459123b42 100644
--- a/docs/pages/_en/1.0/reference/release-notes.md
+++ b/docs/pages/_en/1.0/reference/release-notes.md
@@ -11,14 +11,16 @@ group: Deployment & Configs
### WIP
- Added 'Reference Point' parameter.
-- Added 'Query Analytical Element'
-- Added 'Analytical Element Identity'
-- Added 'Cluster Analytical Elements (Role)'
-- Added 'Add Analytical Element'
-- Added 'Add Model Element'
- Added 'Add Boundary Conditions (Point)'
- Added 'Add Boundary Conditions (Line)'
- Added 'Add Boundary Conditions (Area)'
+- Added 'Boundary Conditions Settings'
+- Added 'Query Boundary Conditions'
+- Added 'Add Analytical Element'
+- Added 'Add Model Element'
+- Added 'Analytical Element Identity'
+- Added 'Cluster Analytical Elements (Role)'
+- Added 'Query Analytical Elements'
### RC
diff --git a/src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs b/src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs
deleted file mode 100644
index 610e9d275..000000000
--- a/src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Autodesk.Revit.DB.Structure
-{
- public enum BoundaryConditionsState
- {
- Fixed = 0,
- Pinned = 1,
- Roller = 2,
- User = 3
- }
-}
diff --git a/src/RhinoInside.Revit.GH/Components/Element/Parameters.cs b/src/RhinoInside.Revit.GH/Components/Element/Parameters.cs
index a91befcce..ee75e5d1c 100644
--- a/src/RhinoInside.Revit.GH/Components/Element/Parameters.cs
+++ b/src/RhinoInside.Revit.GH/Components/Element/Parameters.cs
@@ -74,7 +74,6 @@ internal static IGH_Goo AsGoo(this ARDB.Parameter parameter)
#if REVIT_2023
case ARDB.BuiltInParameter.ANALYTICAL_ELEMENT_STRUCTURAL_ROLE: return new Types.AnalyticalStructuralRole((ARDB.Structure.AnalyticalStructuralRole) integer);
#endif
- case ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET: return new Types.BoundaryConditionsState((ARDB.Structure.BoundaryConditionsState) integer);
}
if (builtInParameter.IsColor())
diff --git a/src/RhinoInside.Revit.GH/Components/Structure/AddAnalyticalElement-Model.cs b/src/RhinoInside.Revit.GH/Components/Structure/AddAnalyticalElement-Model.cs
index 54e473965..389422624 100644
--- a/src/RhinoInside.Revit.GH/Components/Structure/AddAnalyticalElement-Model.cs
+++ b/src/RhinoInside.Revit.GH/Components/Structure/AddAnalyticalElement-Model.cs
@@ -1,5 +1,7 @@
using System;
+using System.Collections.Generic;
using System.Linq;
+using System.Windows.Documents;
using Grasshopper.Kernel;
using Rhino.Geometry;
using RhinoInside.Revit.Convert.Geometry;
@@ -71,6 +73,7 @@ public AddAnalyticalElementByModel() : base
Name = _AnalyticalElement_,
NickName = "AE",
Description = $"Output {_AnalyticalElement_}",
+ Access = GH_ParamAccess.list
}
)
};
@@ -147,7 +150,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
return;
case ARDB.Structure.AnalyticalStructuralRole.StructuralRoleBeam:
- ReconstructElement
+ var beam = ReconstructElement
(
doc.Value, _AnalyticalElement_, analyticalMember =>
{
@@ -155,13 +158,13 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
analyticalMember.StructuralRole = structuralRole;
analyticalMember.SectionTypeId = typeId;
analyticalMember.MaterialId = materialId;
- DA.SetData(_AnalyticalElement_, analyticalMember);
return analyticalMember;
}
);
+ DA.SetDataList(_AnalyticalElement_, new List { beam });
break;
case ARDB.Structure.AnalyticalStructuralRole.StructuralRoleColumn:
- ReconstructElement
+ var column = ReconstructElement
(
doc.Value, _AnalyticalElement_, analyticalMember =>
{
@@ -173,9 +176,10 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
return analyticalMember;
}
);
+ DA.SetDataList(_AnalyticalElement_, new List { column });
break;
case ARDB.Structure.AnalyticalStructuralRole.StructuralRoleGirder:
- ReconstructElement
+ var girder = ReconstructElement
(
doc.Value, _AnalyticalElement_, analyticalMember =>
{
@@ -183,14 +187,14 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
analyticalMember.StructuralRole = structuralRole;
analyticalMember.SectionTypeId = typeId;
analyticalMember.MaterialId = materialId;
- DA.SetData(_AnalyticalElement_, analyticalMember);
return analyticalMember;
}
);
+ DA.SetDataList(_AnalyticalElement_, new List { girder });
break;
case ARDB.Structure.AnalyticalStructuralRole.StructuralRoleMember:
- ReconstructElement
+ var member = ReconstructElement
(
doc.Value, _AnalyticalElement_, analyticalMember =>
{
@@ -198,137 +202,148 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
analyticalMember.StructuralRole = structuralRole;
analyticalMember.SectionTypeId = typeId;
analyticalMember.MaterialId = materialId;
- DA.SetData(_AnalyticalElement_, analyticalMember);
return analyticalMember;
}
);
+ DA.SetDataList(_AnalyticalElement_, new List { member });
break;
case ARDB.Structure.AnalyticalStructuralRole.StructuralRoleFloor:
- ReconstructElement
- (
- doc.Value, _AnalyticalElement_, analyticalPanel =>
- {
- if (boundary.Faces.Count != 1)
- throw new RuntimeArgumentException("Boundary", "Boundary surface should have only one face.", boundary);
-
- if (!boundary.Faces[0].TryGetPlane(out var _, tol.VertexTolerance))
- throw new RuntimeArgumentException("Boundary", "Boundary surface should be planar.", boundary);
- var loops = boundary.Loops.Where(x => x.LoopType == BrepLoopType.Outer).Select(x => x.To3dCurve()).ToArray();
-
- var boundaryPlane = default(Rhino.Geometry.Plane);
- var maxArea = 0.0;
- for (int index = 0; index < loops.Length; ++index)
+ var analyticalPanelsFloors = new List();
+ foreach (var face in boundary.Faces)
+ {
+ var panel = ReconstructElement
+ (
+ doc.Value, _AnalyticalElement_, analyticalPanel =>
{
- var loop = loops[index];
- var plane = default(Rhino.Geometry.Plane);
- if (loop is null || loop.IsShort(tol.ShortCurveTolerance))
- throw new RuntimeArgumentException("Boundary", $"Loop {index} is too short.\nTolerance is {tol.ShortCurveTolerance}", loop);
+ if (!face.TryGetPlane(out var _, tol.VertexTolerance))
+ throw new RuntimeArgumentException("Boundary", "Boundary surface should be planar.", boundary);
- if (!loop.IsClosed(tol.VertexTolerance) || !loop.TryGetPlane(out plane, tol.VertexTolerance))
- throw new RuntimeArgumentException("Boundary", $"Loop {index} should be closed and planar.\nTolerance is {tol.VertexTolerance}", loop);
+ var loops = face.Loops.Where(x => x.LoopType == BrepLoopType.Outer).Select(x => x.To3dCurve()).ToArray();
- loops[index] = loop.Simplify(CurveSimplifyOptions.All & ~CurveSimplifyOptions.Merge, tol.VertexTolerance, tol.AngleTolerance) ?? loop;
-
- using (var properties = AreaMassProperties.Compute(loop, tol.VertexTolerance))
+ var boundaryPlane = default(Rhino.Geometry.Plane);
+ var maxArea = 0.0;
+ for (int index = 0; index < loops.Length; ++index)
{
- if (properties is null)
- throw new RuntimeArgumentException("Boundary", "Failed to compute loop Area.", loop);
+ var loop = loops[index];
+ var plane = default(Rhino.Geometry.Plane);
+ if (loop is null || loop.IsShort(tol.ShortCurveTolerance))
+ throw new RuntimeArgumentException("Boundary", $"Loop {index} is too short.\nTolerance is {tol.ShortCurveTolerance}", loop);
- if (properties.Area > maxArea)
- {
- maxArea = properties.Area;
- var orientation = loop.ClosedCurveOrientation(plane);
+ if (!loop.IsClosed(tol.VertexTolerance) || !loop.TryGetPlane(out plane, tol.VertexTolerance))
+ throw new RuntimeArgumentException("Boundary", $"Loop {index} should be closed and planar.\nTolerance is {tol.VertexTolerance}", loop);
- if (orientation == CurveOrientation.CounterClockwise)
- plane.Flip();
+ loops[index] = loop.Simplify(CurveSimplifyOptions.All & ~CurveSimplifyOptions.Merge, tol.VertexTolerance, tol.AngleTolerance) ?? loop;
- boundaryPlane = plane;
- }
- else if (plane.Normal.IsParallelTo(boundaryPlane.Normal) == 0 || Math.Abs(plane.DistanceTo(boundaryPlane.Origin)) > GeometryTolerance.Internal.DefaultTolerance)
+ using (var properties = AreaMassProperties.Compute(loop, tol.VertexTolerance))
{
- throw new RuntimeArgumentException("Boundary", "Loops should be a list of coplanar curves.", loops);
+ if (properties is null)
+ throw new RuntimeArgumentException("Boundary", "Failed to compute loop Area.", loop);
+
+ if (properties.Area > maxArea)
+ {
+ maxArea = properties.Area;
+ var orientation = loop.ClosedCurveOrientation(plane);
+
+ if (orientation == CurveOrientation.CounterClockwise)
+ plane.Flip();
+
+ boundaryPlane = plane;
+ }
+ else if (plane.Normal.IsParallelTo(boundaryPlane.Normal) == 0 || Math.Abs(plane.DistanceTo(boundaryPlane.Origin)) > GeometryTolerance.Internal.DefaultTolerance)
+ {
+ throw new RuntimeArgumentException("Boundary", "Loops should be a list of coplanar curves.", loops);
+ }
}
+
}
- }
- analyticalPanel = Reconstruct
- (
- analyticalPanel,
- doc.Value,
- loops
- );
-
- analyticalPanel.StructuralRole = structuralRole;
- analyticalPanel.Thickness = thickness;
- DA.SetData(_AnalyticalElement_, analyticalPanel);
- return analyticalPanel;
- }
- );
- break;
- case ARDB.Structure.AnalyticalStructuralRole.StructuralRoleWall:
- ReconstructElement
- (
- doc.Value, _AnalyticalElement_, analyticalPanel =>
- {
- if (boundary.Faces.Count != 1)
- throw new RuntimeArgumentException("Boundary", "Boundary surface should have only one face.", boundary);
+ analyticalPanel = Reconstruct
+ (
+ analyticalPanel,
+ doc.Value,
+ loops
+ );
- if (!boundary.Faces[0].TryGetPlane(out var _, tol.VertexTolerance))
- throw new RuntimeArgumentException("Boundary", "Boundary surface should be planar.", boundary);
+ analyticalPanel.StructuralRole = structuralRole;
+ analyticalPanel.Thickness = thickness;
+ return analyticalPanel;
+ }
+ );
- var loops = boundary.Loops.Where(x => x.LoopType == BrepLoopType.Outer).Select(x => x.To3dCurve()).ToArray();
+ analyticalPanelsFloors.Add(panel);
+ }
+ DA.SetDataList(_AnalyticalElement_, analyticalPanelsFloors);
+ break;
- var boundaryPlane = default(Rhino.Geometry.Plane);
- var maxArea = 0.0;
- for (int index = 0; index < loops.Length; ++index)
+ case ARDB.Structure.AnalyticalStructuralRole.StructuralRoleWall:
+ var analyticalPanelsWalls = new List();
+ foreach (var face in boundary.Faces)
+ {
+ var panel = ReconstructElement
+ (
+ doc.Value, _AnalyticalElement_, analyticalPanel =>
{
- var loop = loops[index];
- var plane = default(Rhino.Geometry.Plane);
- if (loop is null || loop.IsShort(tol.ShortCurveTolerance))
- throw new RuntimeArgumentException("Boundary", $"Loop {index} is too short.\nTolerance is {tol.ShortCurveTolerance}", loop);
+ if (!boundary.Faces[0].TryGetPlane(out var _, tol.VertexTolerance))
+ throw new RuntimeArgumentException("Boundary", "Boundary surface should be planar.", boundary);
- if (!loop.IsClosed(tol.VertexTolerance) || !loop.TryGetPlane(out plane, tol.VertexTolerance))
- throw new RuntimeArgumentException("Boundary", $"Loop {index} should be closed and planar.\nTolerance is {tol.VertexTolerance}", loop);
+ var loops = boundary.Loops.Where(x => x.LoopType == BrepLoopType.Outer).Select(x => x.To3dCurve()).ToArray();
- loops[index] = loop.Simplify(CurveSimplifyOptions.All & ~CurveSimplifyOptions.Merge, tol.VertexTolerance, tol.AngleTolerance) ?? loop;
-
- using (var properties = AreaMassProperties.Compute(loop, tol.VertexTolerance))
+ var boundaryPlane = default(Rhino.Geometry.Plane);
+ var maxArea = 0.0;
+ for (int index = 0; index < loops.Length; ++index)
{
- if (properties is null)
- throw new RuntimeArgumentException("Boundary", "Failed to compute loop Area.", loop);
+ var loop = loops[index];
+ var plane = default(Rhino.Geometry.Plane);
+ if (loop is null || loop.IsShort(tol.ShortCurveTolerance))
+ throw new RuntimeArgumentException("Boundary", $"Loop {index} is too short.\nTolerance is {tol.ShortCurveTolerance}", loop);
- if (properties.Area > maxArea)
- {
- maxArea = properties.Area;
- var orientation = loop.ClosedCurveOrientation(plane);
+ if (!loop.IsClosed(tol.VertexTolerance) || !loop.TryGetPlane(out plane, tol.VertexTolerance))
+ throw new RuntimeArgumentException("Boundary", $"Loop {index} should be closed and planar.\nTolerance is {tol.VertexTolerance}", loop);
- if (orientation == CurveOrientation.CounterClockwise)
- plane.Flip();
+ loops[index] = loop.Simplify(CurveSimplifyOptions.All & ~CurveSimplifyOptions.Merge, tol.VertexTolerance, tol.AngleTolerance) ?? loop;
- boundaryPlane = plane;
- }
- else if (plane.Normal.IsParallelTo(boundaryPlane.Normal) == 0 || Math.Abs(plane.DistanceTo(boundaryPlane.Origin)) > GeometryTolerance.Internal.DefaultTolerance)
+ using (var properties = AreaMassProperties.Compute(loop, tol.VertexTolerance))
{
- throw new RuntimeArgumentException("Boundary", "Loops should be a list of coplanar curves.", loops);
+ if (properties is null)
+ throw new RuntimeArgumentException("Boundary", "Failed to compute loop Area.", loop);
+
+ if (properties.Area > maxArea)
+ {
+ maxArea = properties.Area;
+ var orientation = loop.ClosedCurveOrientation(plane);
+
+ if (orientation == CurveOrientation.CounterClockwise)
+ plane.Flip();
+
+ boundaryPlane = plane;
+ }
+ else if (plane.Normal.IsParallelTo(boundaryPlane.Normal) == 0 || Math.Abs(plane.DistanceTo(boundaryPlane.Origin)) > GeometryTolerance.Internal.DefaultTolerance)
+ {
+ throw new RuntimeArgumentException("Boundary", "Loops should be a list of coplanar curves.", loops);
+ }
}
}
+
+ analyticalPanel = Reconstruct
+ (
+ analyticalPanel,
+ doc.Value,
+ loops
+ );
+
+ analyticalPanel.StructuralRole = structuralRole;
+ analyticalPanel.Thickness = thickness;
+ DA.SetData(_AnalyticalElement_, analyticalPanel);
+ return analyticalPanel;
}
+ );
- analyticalPanel = Reconstruct
- (
- analyticalPanel,
- doc.Value,
- loops
- );
-
- analyticalPanel.StructuralRole = structuralRole;
- analyticalPanel.Thickness = thickness;
- DA.SetData(_AnalyticalElement_, analyticalPanel);
- return analyticalPanel;
- }
- );
+ analyticalPanelsWalls.Add(panel);
+ }
+
+ DA.SetDataList(_AnalyticalElement_, analyticalPanelsWalls);
break;
}
#endif
diff --git a/src/RhinoInside.Revit.GH/Components/Structure/AddAnalyticalMember.cs b/src/RhinoInside.Revit.GH/Components/Structure/AddAnalyticalMember.cs
index be9db20a4..e14d7fe9d 100644
--- a/src/RhinoInside.Revit.GH/Components/Structure/AddAnalyticalMember.cs
+++ b/src/RhinoInside.Revit.GH/Components/Structure/AddAnalyticalMember.cs
@@ -74,17 +74,6 @@ public AddAnalyticalMember() : base
const string _AnalyticalMember_ = "Analytical Member";
-// static readonly ARDB.BuiltInParameter[] ExcludeUniqueProperties =
-// {
-//#if REVIT_2023
-// ARDB.BuiltInParameter.STRUCTURAL_SECTION_SHAPE,
-// ARDB.BuiltInParameter.STRUCTURAL_ANALYZES_AS,
-// ARDB.BuiltInParameter.ANALYTICAL_ELEMENT_STRUCTURAL_ROLE,
-// ARDB.BuiltInParameter.ANALYTICAL_MEMBER_ROTATION,
-// ARDB.BuiltInParameter.ANALYTICAL_MEMBER_SECTION_TYPE
-//#endif
-// };
-
protected override void TrySolveInstance(IGH_DataAccess DA)
{
#if REVIT_2023
@@ -113,52 +102,5 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
);
#endif
}
-
-//#if REVIT_2023
-// bool Reuse
-// (
-// ARDB_AnalyticalMember analyticalMember,
-// ARDB.Curve curve
-// )
-// {
-// if (analyticalMember is null) return false;
-
-// using (var loc = analyticalMember.GetCurve())
-// {
-// if (!loc.IsSameKindAs(curve))
-// return false;
-
-// if (!loc.AlmostEquals(curve, analyticalMember.Document.Application.VertexTolerance))
-// analyticalMember.SetCurve(curve);
-// }
-
-// return true;
-// }
-
-// ARDB_AnalyticalMember Create(ARDB.Document doc, ARDB.Curve curve)
-// {
-// return ARDB_AnalyticalMember.Create(doc, curve);
-// }
-
-// protected ARDB_AnalyticalMember Reconstruct
-// (
-// ARDB_AnalyticalMember analyticalMember,
-// ARDB.Document doc,
-// ARDB.Curve curve
-// )
-// {
-// if (!Reuse(analyticalMember, curve))
-// {
-// analyticalMember = analyticalMember.ReplaceElement
-// (
-// Create(doc, curve),
-// ExcludeUniqueProperties
-// );
-// analyticalMember.Document.Regenerate();
-// }
-
-// return analyticalMember;
-// }
-//#endif
}
}
diff --git a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs
index a4d2d404d..22bed1b69 100644
--- a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs
+++ b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs
@@ -95,8 +95,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
face
);
- DA.SetData(_BoundaryConditions_, boundaryConditions);
- //DA.SetData(_BoundaryConditions_, new AreaBoundaryConditions(boundaryConditions));
+ DA.SetData(_BoundaryConditions_, new AreaBoundaryConditions(boundaryConditions));
return boundaryConditions;
}
);
diff --git a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Line.cs b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Line.cs
index d8743d0ce..cb141bb92 100644
--- a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Line.cs
+++ b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Line.cs
@@ -96,8 +96,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
curve
);
- DA.SetData(_BoundaryConditions_, boundaryConditions);
- //DA.SetData(_BoundaryConditions_, new LineBoundaryConditions(boundaryConditions));
+ DA.SetData(_BoundaryConditions_, new LineBoundaryConditions(boundaryConditions));
return boundaryConditions;
}
);
diff --git a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Point.cs b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Point.cs
index 9b1c7da4b..39bf1e407 100644
--- a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Point.cs
+++ b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Point.cs
@@ -97,8 +97,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
point
);
- DA.SetData(_BoundaryConditions_, boundaryConditions);
- //DA.SetData(_BoundaryConditions_, new PointBoundaryConditions(boundaryConditions));
+ DA.SetData(_BoundaryConditions_, new PointBoundaryConditions(boundaryConditions));
return boundaryConditions;
}
);
diff --git a/src/RhinoInside.Revit.GH/Types/Element.Activator.cs b/src/RhinoInside.Revit.GH/Types/Element.Activator.cs
index 86e014b0c..15d4c39b6 100644
--- a/src/RhinoInside.Revit.GH/Types/Element.Activator.cs
+++ b/src/RhinoInside.Revit.GH/Types/Element.Activator.cs
@@ -107,6 +107,15 @@ public static Element FromElement(ARDB.Element element)
}
break;
+
+ case ARDB.Structure.BoundaryConditions bConditions:
+ switch (bConditions.GetBoundaryConditionsType())
+ {
+ case ARDB.Structure.BoundaryConditionsType.Point: return new PointBoundaryConditions(bConditions);
+ case ARDB.Structure.BoundaryConditionsType.Line: return new LineBoundaryConditions(bConditions);
+ case ARDB.Structure.BoundaryConditionsType.Area: return new AreaBoundaryConditions(bConditions);
+ }
+ break;
}
// By Type
@@ -388,9 +397,6 @@ public static Element FromReference(ARDB.Document doc, ARDB.Reference reference)
{ typeof(ARDB.Structure.LineLoad), (element)=> new LineLoad (element as ARDB.Structure.LineLoad) },
{ typeof(ARDB.Structure.AreaLoad), (element)=> new AreaLoad (element as ARDB.Structure.AreaLoad) },
{ typeof(ARDB.Structure.BoundaryConditions), (element)=> new BoundaryConditions (element as ARDB.Structure.BoundaryConditions) },
- //{ typeof(PointBoundaryConditions), (element)=> new PointBoundaryConditions (element as ARDB.Structure.BoundaryConditions) },
- //{ typeof(LineBoundaryConditions), (element)=> new LineBoundaryConditions (element as ARDB.Structure.BoundaryConditions) },
- //{ typeof(AreaBoundaryConditions), (element)=> new AreaBoundaryConditions (element as ARDB.Structure.BoundaryConditions) },
};
}
}
diff --git a/src/RhinoInside.Revit.GH/Types/Enums.cs b/src/RhinoInside.Revit.GH/Types/Enums.cs
index 974854d55..5117c4335 100755
--- a/src/RhinoInside.Revit.GH/Types/Enums.cs
+++ b/src/RhinoInside.Revit.GH/Types/Enums.cs
@@ -795,23 +795,4 @@ public BoundaryConditionsType(ARDB.Structure.BoundaryConditionsType value) : bas
{ (int) ARDB.Structure.BoundaryConditionsType.Area, "Area" },
};
}
-
- [
- ComponentVersion(introduced: "1.28"),
- ComponentGuid("4244E344-8F5F-4DE7-9ED2-3F031EA91405"),
- Name("Boundary Conditions State"),
- Description("Represents boundary conditions state"),
- ]
- public class BoundaryConditionsState : GH_Enum
- {
- public BoundaryConditionsState() : base() { }
- public BoundaryConditionsState(ARDB.Structure.BoundaryConditionsState value) : base(value) { }
- public static new IReadOnlyDictionary NamedValues { get; } = new Dictionary
- {
- { (int) ARDB.Structure.BoundaryConditionsState.Fixed, "Fixed" },
- { (int) ARDB.Structure.BoundaryConditionsState.Pinned, "Pinned" },
- { (int) ARDB.Structure.BoundaryConditionsState.Roller, "Roller" },
- { (int) ARDB.Structure.BoundaryConditionsState.User, "User" },
- };
- }
}
diff --git a/src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs b/src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs
index 233fb4fa2..c7420d1ec 100644
--- a/src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs
+++ b/src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs
@@ -1,10 +1,10 @@
using System;
-using Grasshopper.Kernel;
+using System.Linq;
using Grasshopper;
+using Grasshopper.Kernel;
using Rhino.Geometry;
-using ARDB = Autodesk.Revit.DB;
using RhinoInside.Revit.Convert.Geometry;
-using System.Linq;
+using ARDB = Autodesk.Revit.DB;
namespace RhinoInside.Revit.GH.Types
{
@@ -12,138 +12,107 @@ namespace RhinoInside.Revit.GH.Types
public class BoundaryConditions : GeometricElement
{
protected override Type ValueType => typeof(ARDB.Structure.BoundaryConditions);
- public ARDB.Structure.BoundaryConditionsState BoundaryConditionsState
- {
- get
- {
- switch (Value?.GetBoundaryConditionsType())
- {
- default:
- case ARDB.Structure.BoundaryConditionsType.Point:
- return (ARDB.Structure.BoundaryConditionsState) Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET).AsInteger();
- case ARDB.Structure.BoundaryConditionsType.Line:
- return (ARDB.Structure.BoundaryConditionsState) Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET_LINEAR).AsInteger();
- case ARDB.Structure.BoundaryConditionsType.Area:
- return (ARDB.Structure.BoundaryConditionsState) Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET_AREA).AsInteger();
- }
- }
- }
+ protected virtual string BoundaryConditionsState => default;
+
public new ARDB.Structure.BoundaryConditions Value => base.Value as ARDB.Structure.BoundaryConditions;
public BoundaryConditions() { }
public BoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
- public Rhino.Display.PointStyle GetPointStyle()
+ protected Rhino.Display.PointStyle GetPointStyle()
{
switch (BoundaryConditionsState)
{
default:
- case ARDB.Structure.BoundaryConditionsState.Fixed: return Rhino.Display.PointStyle.Square;
- case ARDB.Structure.BoundaryConditionsState.Pinned: return Rhino.Display.PointStyle.Clover;
- case ARDB.Structure.BoundaryConditionsState.Roller: return Rhino.Display.PointStyle.Circle;
- case ARDB.Structure.BoundaryConditionsState.User: return Rhino.Display.PointStyle.Asterisk;
+ case "Fixed": return Rhino.Display.PointStyle.Square;
+ case "Pinned": return Rhino.Display.PointStyle.Clover;
+ case "Roller": return Rhino.Display.PointStyle.Circle;
+ case "User": return Rhino.Display.PointStyle.Asterisk;
}
}
+ }
+
+ [Kernel.Attributes.Name("Point Boundary Conditions")]
+ public class PointBoundaryConditions : BoundaryConditions
+ {
+ protected override Type ValueType => typeof(PointBoundaryConditions);
+ protected override string BoundaryConditionsState => Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET).AsValueString();
+ public PointBoundaryConditions() { }
+ public PointBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
+
+ #region Location
+ public override Point3d Position => Value.Point.ToPoint3d();
+ #endregion
+
+ #region IGH_PreviewData
+ protected override void DrawViewportWires(GH_PreviewWireArgs args)
+ {
+ if (Value.Point.ToPoint3d() is Point3d position)
+ args.Pipeline.DrawPoint(position, this.GetPointStyle(), CentralSettings.PreviewPointRadius, args.Color);
+ }
+ #endregion
+ }
+
+ [Kernel.Attributes.Name("Line Boundary Conditions")]
+ public class LineBoundaryConditions : BoundaryConditions
+ {
+ protected override Type ValueType => typeof(LineBoundaryConditions);
+ public LineBoundaryConditions() { }
+ public LineBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
+ protected override string BoundaryConditionsState => Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET_LINEAR).AsValueString();
+
+ #region Location
+ public override Curve Curve => Value?.GetCurve().ToCurve();
+ #endregion
+
#region IGH_PreviewData
protected override void DrawViewportWires(GH_PreviewWireArgs args)
{
- base.DrawViewportWires(args);
- var structuralSettings = ARDB.Structure.StructuralSettings.GetStructuralSettings(Revit.ActiveUIApplication.ActiveUIDocument.Document);
- double spacing = structuralSettings.BoundaryConditionAreaAndLineSymbolSpacing * Revit.ModelUnits;
- var boundaryType = Value.GetBoundaryConditionsType();
- Point3d[] points = null;
+ if (Value?.GetCurve().ToCurve() is Curve curve)
+ {
+ var segments = (int) Math.Ceiling(curve.GetLength() / (ARDB.Structure.StructuralSettings.GetStructuralSettings(Revit.ActiveUIApplication.ActiveUIDocument.Document).BoundaryConditionAreaAndLineSymbolSpacing * Revit.ModelUnits));
+ curve.DivideByCount(segments, true, out Point3d[] points);
+
+ if (points != null)
+ args.Pipeline.DrawPoints(points, this.GetPointStyle(), CentralSettings.PreviewPointRadius, args.Color);
+ }
+ }
+ #endregion
+ }
+
+ [Kernel.Attributes.Name("Area Boundary Conditions")]
+ public class AreaBoundaryConditions : BoundaryConditions
+ {
+ protected override Type ValueType => typeof(AreaBoundaryConditions);
+ public AreaBoundaryConditions() { }
+ public AreaBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
+ protected override string BoundaryConditionsState => Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET_AREA).AsValueString();
- switch (boundaryType)
+ #region Location
+ public override Brep TrimmedSurface
+ {
+ get
{
- case ARDB.Structure.BoundaryConditionsType.Point:
- if (Value.Point.ToPoint3d() is Point3d position)
- args.Pipeline.DrawPoint(position,this.GetPointStyle(),CentralSettings.PreviewPointRadius, args.Color);
- return;
-
- case ARDB.Structure.BoundaryConditionsType.Line:
- {
- if (Value?.GetCurve().ToCurve() is Curve curve)
- curve.DivideByCount((int) Math.Ceiling(curve.GetLength() / spacing), true, out points);
- break;
- }
-
- case ARDB.Structure.BoundaryConditionsType.Area:
- {
- if (GeometryDecoder.ToCurve(Value?.GetLoops().First()) is Curve curve)
- curve.DivideByCount((int) Math.Ceiling(curve.GetLength() / spacing), true, out points);
- break;
- }
+ var loops = Value.GetLoops().First().Select(x => x.ToCurve());
+ return Brep.CreateEdgeSurface(loops);
}
+ }
+ #endregion
+
+ #region IGH_PreviewData
+ protected override void DrawViewportWires(GH_PreviewWireArgs args)
+ {
+ if (GeometryDecoder.ToCurve(Value?.GetLoops().First()) is Curve curve)
+ {
+ var segments = (int) Math.Ceiling(curve.GetLength() / (ARDB.Structure.StructuralSettings.GetStructuralSettings(Revit.ActiveUIApplication.ActiveUIDocument.Document).BoundaryConditionAreaAndLineSymbolSpacing * Revit.ModelUnits));
+ curve.DivideByCount(segments, true, out Point3d[] points);
- if (points != null && points.Length > 0)
- args.Pipeline.DrawPoints(points, this.GetPointStyle(), CentralSettings.PreviewPointRadius, args.Color);
+ if (points != null)
+ args.Pipeline.DrawPoints(points, this.GetPointStyle(), CentralSettings.PreviewPointRadius, args.Color);
+ }
}
#endregion
}
-
- //[Kernel.Attributes.Name("Point Boundary Conditions")]
- //public class PointBoundaryConditions : BoundaryConditions
- //{
- // protected override Type ValueType => typeof(PointBoundaryConditions);
- // public override ARDB.Structure.BoundaryConditionsState BoundaryConditionsState =>
- // (ARDB.Structure.BoundaryConditionsState) Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET).AsInteger();
- // public PointBoundaryConditions() { }
- // public PointBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
-
- // #region IGH_PreviewData
- // protected override void DrawViewportWires(GH_PreviewWireArgs args)
- // {
- // if (Value.Point.ToPoint3d() is Point3d position)
- // args.Pipeline.DrawPoint(position, this.GetPointStyle(), CentralSettings.PreviewPointRadius, args.Color);
- // }
- // #endregion
- //}
-
- //[Kernel.Attributes.Name("Line Boundary Conditions")]
- //public class LineBoundaryConditions : BoundaryConditions
- //{
- // protected override Type ValueType => typeof(LineBoundaryConditions);
- // public LineBoundaryConditions() { }
- // public LineBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
- // public override ARDB.Structure.BoundaryConditionsState BoundaryConditionsState => (ARDB.Structure.BoundaryConditionsState) Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET_LINEAR).AsInteger();
-
- // #region IGH_PreviewData
- // protected override void DrawViewportWires(GH_PreviewWireArgs args)
- // {
- // if (Value?.GetCurve().ToCurve() is Curve curve)
- // {
- // var segments = (int)Math.Ceiling(curve.GetLength() /(ARDB.Structure.StructuralSettings.GetStructuralSettings(Revit.ActiveUIApplication.ActiveUIDocument.Document).BoundaryConditionAreaAndLineSymbolSpacing * Revit.ModelUnits));
- // curve.DivideByCount(segments, true, out Point3d[] points);
-
- // if (points != null)
- // args.Pipeline.DrawPoints(points, this.GetPointStyle(), CentralSettings.PreviewPointRadius, args.Color);
- // }
- // }
- // #endregion
- //}
-
- //[Kernel.Attributes.Name("Area Boundary Conditions")]
- //public class AreaBoundaryConditions : BoundaryConditions
- //{
- // protected override Type ValueType => typeof(AreaBoundaryConditions);
- // public AreaBoundaryConditions() { }
- // public AreaBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
- // public override ARDB.Structure.BoundaryConditionsState BoundaryConditionsState => (ARDB.Structure.BoundaryConditionsState) Value.get_Parameter(ARDB.BuiltInParameter.BOUNDARY_PARAM_PRESET_AREA).AsInteger();
-
- // #region IGH_PreviewData
- // protected override void DrawViewportWires(GH_PreviewWireArgs args)
- // {
- // if (GeometryDecoder.ToCurve(Value?.GetLoops().First()) is Curve curve)
- // {
- // var segments = (int) Math.Ceiling(curve.GetLength() / (ARDB.Structure.StructuralSettings.GetStructuralSettings(Revit.ActiveUIApplication.ActiveUIDocument.Document).BoundaryConditionAreaAndLineSymbolSpacing * Revit.ModelUnits));
- // curve.DivideByCount(segments, true, out Point3d[] points);
-
- // if (points != null)
- // args.Pipeline.DrawPoints(points, this.GetPointStyle(), CentralSettings.PreviewPointRadius, args.Color);
- // }
- // }
- // #endregion
- //}
}