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/Components/Structure/AddBoundaryConditions-Area.cs b/src/RhinoInside.Revit.GH/Components/Structure/AddBoundaryConditions-Area.cs index f206e9da7..a4d2d404d 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 @@ -95,6 +96,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 b566a5747..d8743d0ce 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 @@ -96,6 +97,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 3de5a58c8..9b1c7da4b 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 @@ -97,6 +98,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") { } + //} } 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) }, }; } } 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" }, + }; + } } 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 + //} }