using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;
using System.Runtime.Versioning;
using AppsClient.Profiles;
using AppsClient.Database;
namespace FeMM.Grasshopper.Components.Sections
{
#if NETCOREAPP
[SupportedOSPlatform("windows")]
#endif
public class Nomenclature2RevitGeometricComponent : GH_Component
{
/// <summary>
/// Initializes a new instance of the BeamPropertyComponent class.
/// </summary>
public Nomenclature2RevitGeometricComponent()
: base("Maffeis Name 2 Revit Geometry v2.0", "SG", "Section geometries", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_SECTIONS)
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddTextParameter("Section Name", "N", "The section name with Maffeis Nomenclature", GH_ParamAccess.item);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddTextParameter("Catalogue Name", "N", "Section section name", GH_ParamAccess.item);
pManager.AddTextParameter("Maffeis Name", "MN", "Maffeis section name", GH_ParamAccess.item);
pManager.AddTextParameter("Material Family", "MF", "Material type", GH_ParamAccess.item);
pManager.AddTextParameter("Profile Family", "PF", "Section type", GH_ParamAccess.item);
pManager.AddTextParameter("Tekla Family", "TF", "Tekla family", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_H", "ME_H", "Height Beam (Main)", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_B", "ME_B", "Width Beam (Main/Bottom)", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Bb", "ME_Bb", "Width Bottom Base", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Bt", "ME_Bt", "Width Top Base", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Tfb", "ME_Tfb", "Thickness flange bottom", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Tft", "ME_Tft", "Thickness flange Top", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Tf", "ME_Tf", "Thickness flange", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Tw", "ME_Tw", "Thickness web", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Twb", "ME_Twb", "Secondary thickness web", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_R1", "ME_R1", "Radius 1", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_R2", "ME_R2", "Radius 2", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Iw", "ME_Iw", "Flange Distance", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Hsa", "ME_Hsa", "Secondary Height support (sym.supports)", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Hsb", "ME_Hsb", "Secondary Height support (not sym. supports)", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Bsa", "ME_Bsa", "Secondary base support (sym.supports)", GH_ParamAccess.item);
pManager.AddNumberParameter("ME_Bsb", "ME_Bsb", "Secondary base support (not sym.supports)", GH_ParamAccess.item);
pManager.AddBooleanParameter("ValidMask", "VM", "Is a valid name boolean mask", 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)
{
string maffeisName = "";
if (!DA.GetData(0, ref maffeisName))
return;
var profile = Profiles.GetProfileByMaffeisName(maffeisName);
if (profile == null) {
DA.SetData(21, false);
return;
}
int item = 0;
DA.SetData(item++, profile.Name);
DA.SetData(item++, profile.MaffeisName);
DA.SetData(item++, profile.MaterialType.ToString());
DA.SetData(item++, profile.RevitFamily);
DA.SetData(item++, profile.TeklaName);
DA.SetData(item++, profile.H);
DA.SetData(item++, profile.B);
DA.SetData(item++, profile.Bb);
DA.SetData(item++, profile.Bt);
DA.SetData(item++, profile.Tfb);
DA.SetData(item++, profile.Tft);
DA.SetData(item++, profile.Tf);
DA.SetData(item++, profile.Tw);
DA.SetData(item++, profile.Twb);
DA.SetData(item++, profile.R1);
DA.SetData(item++, profile.R2);
DA.SetData(item++, profile.Iw);
DA.SetData(item++, profile.Hsa);
DA.SetData(item++, profile.Hsb);
DA.SetData(item++, profile.Bsa);
DA.SetData(item++, profile.Bsb);
DA.SetData(item++, profile.Shape != DBProfileShape.ALL && (profile.Custom || profile.Name != ""));
}
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon => Properties.Resources.SectionRevit2GeometricIcon;
public override GH_Exposure Exposure => GH_Exposure.tertiary;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new("c86d9dfe-37bd-420e-96e2-c0f405caf91e");
}
}