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

Boundary Conditions Preview #1264

Merged
merged 5 commits into from
Dec 27, 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
10 changes: 10 additions & 0 deletions src/RhinoInside.Revit.External/DB/BoundaryConditionsState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Autodesk.Revit.DB.Structure
{
public enum BoundaryConditionsState
{
Fixed = 0,
Pinned = 1,
Roller = 2,
User = 3
}
}
1 change: 1 addition & 0 deletions src/RhinoInside.Revit.GH/Components/Element/Parameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,6 +96,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
);

DA.SetData(_BoundaryConditions_, boundaryConditions);
//DA.SetData(_BoundaryConditions_, new AreaBoundaryConditions(boundaryConditions));
return boundaryConditions;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,6 +97,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
);

DA.SetData(_BoundaryConditions_, boundaryConditions);
//DA.SetData(_BoundaryConditions_, new LineBoundaryConditions(boundaryConditions));
return boundaryConditions;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -97,6 +98,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
);

DA.SetData(_BoundaryConditions_, boundaryConditions);
//DA.SetData(_BoundaryConditions_, new PointBoundaryConditions(boundaryConditions));
return boundaryConditions;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@ public class BoundaryConditions : GraphicalElement<Types.BoundaryConditions, ARD
public override Guid ComponentGuid => 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<Types.PointBoundaryConditions, ARDB.Structure.BoundaryConditions>
//{
// 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<Types.LineBoundaryConditions, ARDB.Structure.BoundaryConditions>
//{
// 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<Types.AreaBoundaryConditions, ARDB.Structure.BoundaryConditions>
//{
// 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") { }
//}
}
3 changes: 3 additions & 0 deletions src/RhinoInside.Revit.GH/Types/Element.Activator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
};
}
}
21 changes: 20 additions & 1 deletion src/RhinoInside.Revit.GH/Types/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ARDB.Structure.BoundaryConditionsType>
{
public BoundaryConditionsType() : base() { }
Expand All @@ -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<ARDB.Structure.BoundaryConditionsState>
{
public BoundaryConditionsState() : base() { }
public BoundaryConditionsState(ARDB.Structure.BoundaryConditionsState value) : base(value) { }
public static new IReadOnlyDictionary<int, string> NamedValues { get; } = new Dictionary<int, string>
{
{ (int) ARDB.Structure.BoundaryConditionsState.Fixed, "Fixed" },
{ (int) ARDB.Structure.BoundaryConditionsState.Pinned, "Pinned" },
{ (int) ARDB.Structure.BoundaryConditionsState.Roller, "Roller" },
{ (int) ARDB.Structure.BoundaryConditionsState.User, "User" },
};
}
}
148 changes: 127 additions & 21 deletions src/RhinoInside.Revit.GH/Types/Structure/BoundaryConditions.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,149 @@
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
{
[Kernel.Attributes.Name("Boundary Conditions")]
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
//}
}

Loading