using FeMM.Common.Models;
using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;
namespace FeMM.Grasshopper.Components.Sections
{
public class BeamSectionSolidRectComponent : GH_Component
{
/// <summary>
/// Initializes a new instance of the BeamSectionSolidRectComponent class.
/// </summary>
public BeamSectionSolidRectComponent()
: base("Solid Rect", "SR", "Defines a solid rect beam section", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_SECTIONS)
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddNumberParameter("Height", "D", "The section height", GH_ParamAccess.item);
pManager.AddNumberParameter("Base", "B", "The section base", GH_ParamAccess.item);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Section", "S", "The solid rect section", GH_ParamAccess.item);
}
/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
double d = 0, b = 0;
if (!DA.GetData(0, ref d))
return;
if (!DA.GetData(1, ref b))
return;
var sectionModel = new SectionModel()
{
SectionType = SectionModel.SectionTypes.SolidRectangle,
D = d,
B = b
};
sectionModel.CalculateSection();
var section = new GH_BeamSection(sectionModel);
DA.SetData(0, section);
}
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon => Properties.Resources.SolidRectBeamSectionIcon;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new("c68750fa-b296-4dab-ab51-8e9ff9ea2b27");
}
}