algorithmic modeling for Rhino
Hi, I'm trying to make a component that either accepts lines or numbers in the same parameter
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddGenericParameter("stuff", "s", "line or number", GH_ParamAccess.list);
}
In solveInstance I have tried
List<Line> lineList= new List<Line>(); ;
List<double> numberList= new List<double>();if ((!DA.GetDataList(0, lineList)))
if ((!DA.GetDataList(0, numberList)))
return;
and (not so pretty use of try statements....)
try{DA.GetDataList(0, lineList)}
catch{}
try{DA.GetDataList(0, nuimberList)}
catch{}
Both give casting error.. What am I doing wrong?
Tags:
To add to this. I do not want to accept a list of BOTH numbers and lines, but one or the other.
Thank you very much for your reply!
However, I'm not sure I know exactly how to proceed, and how to implement the advice you're giving (still fairly new to component development). Basically, all I need is the length of the lines as soon as they are inputted, so my pseudo code would be something like
input; //Either List of numbers or list of lines
List numberList;
if Input.isAListOfNumbers:
numberList = input
else if Input.isAListOfLines:
foreach line in input:
numberlist.Add(line.length)
else
show error
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
© 2024 Created by Scott Davidson. Powered by