From 6232b6f365b55e5976c744199321cb2538720633 Mon Sep 17 00:00:00 2001
From: Pedro Cortes
Date: Tue, 24 Dec 2024 08:34:47 +0100
Subject: [PATCH 1/4] Commented out new types in activator
---
src/RhinoInside.Revit.GH/Types/Element.Activator.cs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/RhinoInside.Revit.GH/Types/Element.Activator.cs b/src/RhinoInside.Revit.GH/Types/Element.Activator.cs
index 39c4c922b..86e014b0c 100644
--- a/src/RhinoInside.Revit.GH/Types/Element.Activator.cs
+++ b/src/RhinoInside.Revit.GH/Types/Element.Activator.cs
@@ -388,6 +388,9 @@ 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) },
};
}
}
From af634f0ef862b6a869e9e9740d816ce4780ec84d Mon Sep 17 00:00:00 2001
From: Pedro Cortes
Date: Tue, 24 Dec 2024 08:36:12 +0100
Subject: [PATCH 2/4] Created enum for boundary conditions state
---
.../DB/BoundaryConditionsState.cs | 10 +++++++++
.../Components/Element/Parameters.cs | 1 +
src/RhinoInside.Revit.GH/Types/Enums.cs | 21 ++++++++++++++++++-
3 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs
diff --git a/src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs b/src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs
new file mode 100644
index 000000000..610e9d275
--- /dev/null
+++ b/src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs
@@ -0,0 +1,10 @@
+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 ee75e5d1c..a91befcce 100644
--- a/src/RhinoInside.Revit.GH/Components/Element/Parameters.cs
+++ b/src/RhinoInside.Revit.GH/Components/Element/Parameters.cs
@@ -74,6 +74,7 @@ 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/Types/Enums.cs b/src/RhinoInside.Revit.GH/Types/Enums.cs
index c1ff3d22f..974854d55 100755
--- a/src/RhinoInside.Revit.GH/Types/Enums.cs
+++ b/src/RhinoInside.Revit.GH/Types/Enums.cs
@@ -783,7 +783,7 @@ public AnalyzeAs(ARDB.Structure.AnalyzeAs value) : base(value) { }
ComponentGuid("13D4AF7E-AB1E-4628-91A6-C6A523898334"),
Name("Boundary Conditions Type"),
Description("Represents boundary conditions type"),
-]
+ ]
public class BoundaryConditionsType : GH_Enum
{
public BoundaryConditionsType() : base() { }
@@ -795,4 +795,23 @@ 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" },
+ };
+ }
}
From 140eff79aa1bba8efa74d5929c596a8dd6b61f3b Mon Sep 17 00:00:00 2001
From: Pedro Cortes
Date: Tue, 24 Dec 2024 12:49:01 +0100
Subject: [PATCH 3/4] Commented out new specific params for boundary conditions
---
.../Structure/AddBoundaryConditions-Area.cs | 2 ++
.../Structure/AddBoundaryConditions-Line.cs | 2 ++
.../Structure/AddBoundaryConditions-Point.cs | 2 ++
.../Structure/BoundaryConditions.cs | 28 ++++++++++++++++++-
4 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs
index 4b4af056d..fbeb74549 100644
--- a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs
+++ b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs
@@ -4,6 +4,7 @@
using Grasshopper.Kernel;
using RhinoInside.Revit.Convert.Geometry;
using RhinoInside.Revit.External.DB.Extensions;
+using RhinoInside.Revit.GH.Types;
using ARDB = Autodesk.Revit.DB;
namespace RhinoInside.Revit.GH.Components.Structure
@@ -92,6 +93,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
);
DA.SetData(_BoundaryConditions_, 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 ad175ef0e..c863175e3 100644
--- a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Line.cs
+++ b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Line.cs
@@ -2,6 +2,7 @@
using Autodesk.Revit.DB.Structure;
using Grasshopper.Kernel;
using RhinoInside.Revit.External.DB.Extensions;
+using RhinoInside.Revit.GH.Types;
using ARDB = Autodesk.Revit.DB;
namespace RhinoInside.Revit.GH.Components.Structure
@@ -93,6 +94,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
);
DA.SetData(_BoundaryConditions_, 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 7de77d24f..abc186ae5 100644
--- a/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Point.cs
+++ b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Point.cs
@@ -3,6 +3,7 @@
using Grasshopper.Kernel;
using RhinoInside.Revit.Convert.Geometry;
using RhinoInside.Revit.External.DB.Extensions;
+using RhinoInside.Revit.GH.Types;
using ARDB = Autodesk.Revit.DB;
namespace RhinoInside.Revit.GH.Components.Structure
@@ -94,6 +95,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
);
DA.SetData(_BoundaryConditions_, boundaryConditions);
+ //DA.SetData(_BoundaryConditions_, new PointBoundaryConditions(boundaryConditions));
return boundaryConditions;
}
);
diff --git a/src/RhinoInside.Revit.GH/Parameters/Structure/BoundaryConditions.cs b/src/RhinoInside.Revit.GH/Parameters/Structure/BoundaryConditions.cs
index e555951bc..94ba46fea 100644
--- a/src/RhinoInside.Revit.GH/Parameters/Structure/BoundaryConditions.cs
+++ b/src/RhinoInside.Revit.GH/Parameters/Structure/BoundaryConditions.cs
@@ -11,6 +11,32 @@ public class BoundaryConditions : GraphicalElement new Guid("DEE191F4-9D73-46C7-9BD0-EBBBD5B8D4A6");
public BoundaryConditions() : base("Boundary Conditions", "Boundary Conditions", "Contains a collection of Revit Boundary Conditions", "Params", "Revit Elements") { }
-
}
+
+ //[ComponentVersion(introduced: "1.27")]
+ //public class PointBoundaryConditions : GraphicalElement
+ //{
+ // public override GH_Exposure Exposure => GH_Exposure.quarternary | GH_Exposure.obscure;
+ // public override Guid ComponentGuid => new Guid("475B48F4-D900-43EB-BD48-B9B683291EFF");
+
+ // public PointBoundaryConditions() : base("Point Boundary Conditions", " Point Boundary Conditions", "Contains a collection of Revit Point Boundary Conditions", "Params", "Revit Elements") { }
+ //}
+
+ //[ComponentVersion(introduced: "1.27")]
+ //public class LineBoundaryConditions : GraphicalElement
+ //{
+ // public override GH_Exposure Exposure => GH_Exposure.quarternary | GH_Exposure.obscure;
+ // public override Guid ComponentGuid => new Guid("0B3DD84D-A8F1-425D-B37C-00986EA35D34");
+
+ // public LineBoundaryConditions() : base("Line Boundary Conditions", " Line Boundary Conditions", "Contains a collection of Revit Line Boundary Conditions", "Params", "Revit Elements") { }
+ //}
+
+ //[ComponentVersion(introduced: "1.27")]
+ //public class AreaBoundaryConditions : GraphicalElement
+ //{
+ // public override GH_Exposure Exposure => GH_Exposure.quarternary | GH_Exposure.obscure;
+ // public override Guid ComponentGuid => new Guid("8FB5CB17-3A19-4FE7-A210-70B6DF88A8A5");
+
+ // public AreaBoundaryConditions() : base("Area Boundary Conditions", "Area Boundary Conditions", "Contains a collection of Revit Area Boundary Conditions", "Params", "Revit Elements") { }
+ //}
}
From 65a4c3552fd8bbd873485fae7ac5650773edc166 Mon Sep 17 00:00:00 2001
From: Pedro Cortes
Date: Tue, 24 Dec 2024 12:51:48 +0100
Subject: [PATCH 4/4] Boundary Conditions preview
---
.../Types/Structure/BoundaryConditions.cs | 148 +++++++++++++++---
1 file changed, 127 insertions(+), 21 deletions(-)
diff --git a/src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs b/src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs
index 562652e35..233fb4fa2 100644
--- a/src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs
+++ b/src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs
@@ -1,5 +1,10 @@
using System;
+using Grasshopper.Kernel;
+using Grasshopper;
+using Rhino.Geometry;
using ARDB = Autodesk.Revit.DB;
+using RhinoInside.Revit.Convert.Geometry;
+using System.Linq;
namespace RhinoInside.Revit.GH.Types
{
@@ -7,37 +12,138 @@ 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();
+ }
+ }
+ }
public new ARDB.Structure.BoundaryConditions Value => base.Value as ARDB.Structure.BoundaryConditions;
public BoundaryConditions() { }
public BoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
- }
- [Kernel.Attributes.Name("Point Boundary Conditions")]
- public class PointBoundaryConditions : GeometricElement
- {
- protected override Type ValueType => typeof(PointBoundaryConditions);
+ public 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;
+ }
+ }
- public PointBoundaryConditions() { }
- public PointBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
- }
+ #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;
- [Kernel.Attributes.Name("Line Boundary Conditions")]
- public class LineBoundaryConditions : GeometricElement
- {
- protected override Type ValueType => typeof(LineBoundaryConditions);
+ switch (boundaryType)
+ {
+ case ARDB.Structure.BoundaryConditionsType.Point:
+ if (Value.Point.ToPoint3d() is Point3d position)
+ args.Pipeline.DrawPoint(position,this.GetPointStyle(),CentralSettings.PreviewPointRadius, args.Color);
+ return;
- public LineBoundaryConditions() { }
- public LineBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
- }
+ case ARDB.Structure.BoundaryConditionsType.Line:
+ {
+ if (Value?.GetCurve().ToCurve() is Curve curve)
+ curve.DivideByCount((int) Math.Ceiling(curve.GetLength() / spacing), true, out points);
+ break;
+ }
- [Kernel.Attributes.Name("Area Boundary Conditions")]
- public class AreaBoundaryConditions : GeometricElement
- {
- protected override Type ValueType => typeof(LineBoundaryConditions);
+ 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;
+ }
+ }
- public AreaBoundaryConditions() { }
- public AreaBoundaryConditions(ARDB.Structure.BoundaryConditions boundaryConditions) : base(boundaryConditions) { }
+ if (points != null && points.Length > 0)
+ 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
+ //}
}