When developing for Grasshopper, it is useful to be able to interact programatically with existing components.
The current SDK has patchy documentation and finding where and how to interact with different components can be challenging.
The script below can be used to find the namespace and class for any component. Use a default C# component. Set the first input (x) as a list, and connect your components to this.
Grasshopper.Kernel.IGH_Param selNumsInput = Component.Params.Input;
IList<Grasshopper.Kernel.IGH_Param> sources = selNumsInput.Sources;
bool isAnythingConnected = sources.Any();
var rtnlist = new List<object>();
foreach (var source in sources)
IGH_DocumentObject component = source.Attributes.GetTopLevel.DocObject;
A = rtnlist;
Once you have these namespaces, you can then dig into these components and access a wide range of properties. It’s quite fun to see what you can do with them.