Hello, sure a stupid question but how to dynamically override an input value list in c#? I’m trying to override a second list (specify the selection) similar to Excel Indirect. For example, if the first input is “construction board” then the second value input list should be overwritten with the values “GKB, GKBI, GKF”, if “construction board” then “GKB, GKBI” and so on. I’m trying to learn how it can be implemented in Grasshopper C# and don’t need a complete script for now, starting points on how to specify it or a simple example would be nice. Thanks for every help
Hi, could you make a sketch? What is the concrete data passed in, and how should the data returned look alike? At least for me, it is not clear what you want to achieve at all!
If Input1 equals “Ausbauplatte” then Input2 should be dynamically filled with the values, the same with “Bauplatte” etc.
I managed to create and connect a dropdown field but so far I haven’t been able to find a way to filter the second input based on the first and set it with the correct values.
But how do I get it out of this (pic 2)
that will be (picture 3)?
Hi, you can use a simple dictionary.
A script component holds a static dictionary. Use a string as key, and an array of strings as values. You can either fill it once from your excel file or you hard-code it. The keys are in those of col A and the values are those strings found in B-F. For selection you just give a string like “Ausbauplatte” and you get the all strings of col B back. I’m pretty sure you can also achieve that in plain GH.
If you are still stuck, let me know and I’ll code an example.
You can use a backslash:
Print("one \" two");
one " two
Read here Strings in C# and .NET
So just do:
var item1 = new Grasshopper.Kernel.Special.GH_ValueListItem("Ausbauplatte", "\"Ausbauplatte\"");
I’m not on a pc right now, so I cant test this…
Thank you, it works now to display the list of values as strings.
Do you have an idea or solution to overwrite the second input? As in the second message example, if I try to replace the list with (this.Component.Params.Input.ReplaceSource(…,…); nothing happens, same if I try to delete the second input object and recreate it with new ValueList items.
I do not know how to continue
Can you attach your current file?
enclosed my script and thanks for your help.
_Trockenbau_Platten.gh (8.6 KB)