Skip to content

Commit

Permalink
Added ARDB.Structure.LoadBase type wrappers.
Browse files Browse the repository at this point in the history
  • Loading branch information
kike-garbo committed Dec 3, 2024
1 parent d86f448 commit a2e8e9e
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/RhinoInside.Revit.GH/Types/Element.Activator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ public static Element FromReference(ARDB.Document doc, ARDB.Reference reference)
{ typeof(ARDB.Structure.AnalyticalModelStick), (element)=> new AnalyticalMember (element as ARDB.Structure.AnalyticalModelStick) },
{ typeof(ARDB.Structure.AnalyticalModelSurface),(element)=> new AnalyticalSurface (element as ARDB.Structure.AnalyticalModelSurface) },
#endif
{ typeof(ARDB.Structure.LoadBase), (element)=> new LoadElement (element as ARDB.Structure.LoadBase) },
{ typeof(ARDB.Structure.PointLoad), (element)=> new PointLoad (element as ARDB.Structure.PointLoad) },
{ typeof(ARDB.Structure.LineLoad), (element)=> new LineLoad (element as ARDB.Structure.LineLoad) },
{ typeof(ARDB.Structure.AreaLoad), (element)=> new AreaLoad (element as ARDB.Structure.AreaLoad) },
};
}
}
86 changes: 86 additions & 0 deletions src/RhinoInside.Revit.GH/Types/Structure/LoadElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using Rhino.Geometry;
using Grasshopper;
using Grasshopper.Kernel;
using ARDB = Autodesk.Revit.DB;

namespace RhinoInside.Revit.GH.Types
{
[Kernel.Attributes.Name("Load Element")]
public class LoadElement : GeometricElement
{
protected override Type ValueType => typeof(ARDB.Structure.LoadBase);
public new ARDB.Structure.LoadBase Value => base.Value as ARDB.Structure.LoadBase;

public LoadElement() { }
public LoadElement(ARDB.Structure.LoadBase element) : base(element) { }
}
}

namespace RhinoInside.Revit.GH.Types
{
using Convert.Geometry;

[Kernel.Attributes.Name("Point Load")]
public class PointLoad : LoadElement
{
protected override Type ValueType => typeof(PointLoad);
public new ARDB.Structure.PointLoad Value => base.Value as ARDB.Structure.PointLoad;

public PointLoad() { }
public PointLoad(ARDB.Structure.PointLoad element) : base(element) { }

#region Location
public override Point3d Position => Value?.Point.ToPoint3d() ?? NaN.Point3d;
#endregion

#region IGH_PreviewData
protected override void DrawViewportWires(GH_PreviewWireArgs args)
{
var position = Position;
if (position.IsValid)
args.Pipeline.DrawPoint(position, CentralSettings.PreviewPointStyle, CentralSettings.PreviewPointRadius, args.Color);
}
#endregion
}
}

namespace RhinoInside.Revit.GH.Types
{
using Convert.Geometry;

[Kernel.Attributes.Name("Line Load")]
public class LineLoad : LoadElement
{
protected override Type ValueType => typeof(LineLoad);
public new ARDB.Structure.LineLoad Value => base.Value as ARDB.Structure.LineLoad;

public LineLoad() { }
public LineLoad(ARDB.Structure.LineLoad element) : base(element) { }

#region Location
public override Curve Curve => Value?.GetCurve().ToCurve() ?? default;
#endregion

#region IGH_PreviewData
protected override void DrawViewportWires(GH_PreviewWireArgs args)
{
if (Curve is Curve curve)
args.Pipeline.DrawCurve(curve, args.Color, args.Thickness);
}
#endregion
}
}

namespace RhinoInside.Revit.GH.Types
{
[Kernel.Attributes.Name("Area Load")]
public class AreaLoad : LoadElement
{
protected override Type ValueType => typeof(AreaLoad);
public new ARDB.Structure.AreaLoad Value => base.Value as ARDB.Structure.AreaLoad;

public AreaLoad() { }
public AreaLoad(ARDB.Structure.AreaLoad element) : base(element) { }
}
}

0 comments on commit a2e8e9e

Please sign in to comment.