Grasshopper

algorithmic modeling for Rhino

How to get the component that links with the current component in Grasshopper?

Hello,

I get one question. I have two components here, and now I want use some Input parameters of component 1(BUI Modifier) inside component 2(Connector). Is that possible? I think, as those two components are connected, there is maybe a brigde between them.

best regards

Yi

Views: 2027

Replies to This Discussion

Still can not find a solution

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

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service