algorithmic modeling for Rhino
Hi,
I am creating a grasshopper custom component. I only either one of the input (BoundaryCrv or GridCrvs) to receive data to the custom component. However, right now the custom component needs both inputs to run (please refer to the image)
Currently, here is how I set the data:
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
//Create default size
double defaultBaySize = 0;
pManager.AddTextParameter("LotLib", "Llib", "Lot Library", GH_ParamAccess.tree);
pManager.AddCurveParameter("BoundaryCrv", "BC", "Boundary Input", GH_ParamAccess.list);
pManager.AddIntegerParameter("Direction", "D", "Direction of gridLines", GH_ParamAccess.item, 0);
pManager.AddNumberParameter("CCsize", "S", "Distance from column to column", GH_ParamAccess.item, defaultBaySize);
pManager.AddCurveParameter("GridCrv", "GC", "Take in curves input for gridlines", GH_ParamAccess.list);
}
protected override void SolveInstance(IGH_DataAccess DA)
{/* Setup */
GH_Structure<GH_String> LotLib = new GH_Structure<GH_String>();
DA.GetDataTree(0, out LotLib);
List<Curve> BoundaryCrv = new List<Curve>();
if(!DA.GetDataList(1, BoundaryCrv)) { return; }
int Direction = 0;
DA.GetData(2, ref Direction);
double CCsize = 0;
DA.GetData(3, ref CCsize);
List<Curve> GridCrvs = new List<Curve>();
DA.GetDataList(4, GridCrvs);
if (!DA.GetDataList(4, GridCrvs)) { return; }}
Is there a way can set data in the way if the component does not receive inputs for BoundaryCrv but only GridCrvs, the BoundaryCrv List will empty.
Thank you very much
Tags:
I am not sure but if there are no inputs in BoundaryCrv you could test
if (BoundaryCrv != null)
{
do things with Boundry crv
}
else
{
if (GridCrvs!= null)
{
do things with GridCrvs
}
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by