Grasshopper

algorithmic modeling for Rhino

How to let grasshopper custom components run without all inputs

Hi 

I am wondering how can I let the custom components run without all the inputs. For example, if either or the BoundaryCrv or GridCrvs receive the input, the custom component will run. Right now, the custom component needs to receive both inputs (refer to the image)

So for example, if I only have BoundaryCrv, the list GridCrvs will be empty and vice versa

/* Code */

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);
if (CCsize == 0) {
double colS = cz.ToDouble(cz.vLookup(LotLib, "column", "SizeX"));
double sideS = cz.ToDouble(cz.vLookup(LotLib, "lotside", "SizeX"));
double midS = cz.ToDouble(cz.vLookup(LotLib, "lotmid", "SizeX"));
CCsize = colS + sideS + midS;
}
List<Curve> GridCrvs = new List<Curve>();
if (!DA.GetDataList(4, GridCrvs)) { return; }}

Views: 308

Replies to This Discussion

Thank you very much for the reply! I will give it a try. Yeah this line (DA.GetDataList(4, GridCrvs);) was commented but i forgot to change when copy over to the thread. Thanks

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service