Hi everybody,
Is it possible to get the values of a component input by index, instead of the input name?
I want to get the data from an input, independent of changes to its name. The input is part of a GHPython component,
Thanks.
Hi everybody,
Is it possible to get the values of a component input by index, instead of the input name?
I want to get the data from an input, independent of changes to its name. The input is part of a GHPython component,
Thanks.
private void GetComponentParams()
{
for (int i = 0; i < GrasshopperDocument.Objects.Count; i++)
{
if(GrasshopperDocument.Objects[i].ComponentGuid != this.Component.ComponentGuid)
{
if( GrasshopperDocument.Objects[i] is GH_Component)
{
GH_Component comp =GrasshopperDocument.Objects[i] as GH_Component;
// Here you have access to the actual inputs
// You can retreive any by index... ect
// As a place holder I am just printing out the names
List<IGH_Param> inputs = comp.Params.Input;
for (int j = 0; j < inputs.Count; j++)
Print(inputs[j].Name.ToString());
}
}
}
}
https://developer.rhino3d.com/5/api/grasshopper/html/T_Grasshopper_Kernel_GH_Component.htm
https://developer.rhino3d.com/5/api/grasshopper/html/T_Grasshopper_Kernel_IGH_Param.htm
Thank you for your answer, but I’m not looking to get the input name, but the value that is input! Let’s say the first input is called ‘x’ and the user input is an integer 4. Now, I want to get the value of 4 only knowing that I want to get it from the first input.
Yeah, In that case just use the other methods that the IGH_Param
provides. Like VolatileData
as @Mahdiyar showed you. I just got the names as a place holder. What VolatileData
returns is just a IGH_Structure
. Check the docs