using FeMM.Common.Models;
using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;
using System.Runtime.Versioning;
namespace FeMM.Grasshopper.Components.Attributes
{
#if NETCOREAPP
[SupportedOSPlatform("windows")]
#endif
public class LoadTransferComponent : GH_Component
{
/// <summary>
/// Initializes a new instance of the BeamReleasesComponent class.
/// </summary>
public LoadTransferComponent()
: base("Load Transfer", "LT", "It indicates whether the frame receives load from an area object when the area object is loaded with " +
"a load of type uniform to frame (only for SAP)", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_ATTRIBUTES)
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Beam", "B", "The beam where define if receives the area load", GH_ParamAccess.item);
pManager.AddBooleanParameter("Transfer", "T", "Indicates if load is allowed to be transferred from area objects to this frame object", GH_ParamAccess.item, true);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Beam", "B", "The modified beam", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
GH_Beam beam = null;
bool tranfer = false;
if (!DA.GetData(0, ref beam))
return;
if (!DA.GetData(1, ref tranfer))
return;
var newBeam = new GH_Beam(beam);
var attributeData = new LoadTransferModel.AttributeData()
{
LoadTransfer = tranfer,
};
var loadTransferModel = new LoadTransferModel(attributeData);
newBeam.Value.Attributes.Add(loadTransferModel);
DA.SetData("Beam", newBeam);
}
public override GH_Exposure Exposure => GH_Exposure.secondary;
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon => Properties.Resources.LoadTransferIcon;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new("3fecca19-7158-4669-a835-dd3ac9d4cd91");
}
}