algorithmic modeling for Rhino
Tags:
Try:
input.VolatileData.AllData(true);
and how can I get the value with this enumerator? I don't understand this term enumerator very well
Thanks Mostapha, i got it! In deed I have no idea of the data structure inside grasshopper or rhino. I can just test the methods one by one.
foreach (IGH_Param input in ghComponent.Params.Input)
{
IGH_StructureEnumerator enumInput = input.VolatileData.AllData(true);
switch (input.Name)
{
case "EW Type":
EW_ID = enumInput.First().ToString();
break;case "PW Type":
PW_ID = enumInput.First().ToString();
break;case "IF Type":
IF_ID = enumInput.First().ToString();
break;case "WIN Type":
WIN_ID = enumInput.First().ToString();
break;
}
}
Never use an enumerator directly. They are only meant to be used in foreach loops.
foreach (object obj in input.VolatileData.AllData(true))
{
.... do logic here.
}
--
David Rutten
david@mcneel.com
I tested it with sequence today, the last code was not exactly the right anwser. The First() method causes the issue. Only the first element will be read at each time. So I think I should use GetEnumerator().Current instead. But I get the "1. Solution exception:Object reference not set to an instance of an object." Runtime Error. I can still not work out. I'm missing some basic knowledge here.
Hi Yi, My knowledge with C# is so limited. I'm pretty sure there is a way to handle enumerators.
For now why don't you convert the Enumerate to a list first? Then it should be easy to get the items out. (http://stackoverflow.com/questions/1167361/how-do-i-convert-an-enum...)
Interesting
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