Grasshopper

algorithmic modeling for Rhino

Hi guys, 

Does anyone know how to properly make a component which can fold and unfold with some additional DataTree or List input? I follow up these two discussions (discussion1 anddiscussion2) and make this example. However, I still have minor bugs.

Whenever I save and reopen the file, I could not unclick the drop down menu to fold the additional input. See pictures below. 

1. When I open the gh file.

2. The input is not folded. 

3. When I click again, additional input is now duplicated with itself. 

Does anyone know how to fix this situation? Any comment will be appreciated. 

I attach the C# file below. Thanks! 

Views: 681

Attachments:

Replies to This Discussion

Hi kao.gene,

David discusses this topic on the ZUI page.

Thanks

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi Giulio, 

Thanks for the quick reply. 

However, instead of using ZUI which can zoom and add input, I prefer to use drop down menu for my component. Because I would like to have a component which has three different optional inputs(maybe list or tree), and three of them have nothing to do with each other. But the user has to explicitly specify which kind of advance input he/she wants to unfold. 

Any more suggestion? thank you in advance :)

Best, 

Gene

It's possible, but it's going to involve some tricky code because you're circumventing the standard procedure.

You should still implement IGH_VariableParameterComponent, as that will make (de)serialization of your component work better. Then you'll have to implement all properties and methods of IGH_VariableParameterComponent, but you can just do nothing in them, or return false.

You can modify the inputs/outputs of a component via the Params.RegisterXXXXX and Params.UnregisterXXXX methods. Just be sure to always call Params.OnParametersChanged when you're done.

You may also want to add a class level variable to your component class which stores what 'mode' your component is currently in. You'll have to override the Read and Write methods in order to store this data in the *.gh file as well. You don't technically need to do this as you can probably figure out the mode based on the input/output layout, but it's always a good idea to store states that you know much be correct.

I can have a look at your code later tonight.

Try this. I made it slightly more complex (toggling between 3 states, rather than two) for educational purposes.

Attachments:

Hi David, 

Thank you so much! This is exactly what I want. Boom! Magic!

The source code and your explanation are super clear. :D

Best, 

Gene

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