Hi everyone,
I am looking for a way to get information for the access types of the input and output parameters for multiple components. I am using the following script to get the GUID of the component, and together with that, I need for each one of the input and output parameters their type, name and their access type.
private void RunScript(ref object Guids, ref object Names, ref object Inputs, ref object InAccess, ref object Outputs, ref object OutAccess)
{
var ids = new List<Guid>();
var names = new List<string>();
var inputs = new DataTree<string>();
var inAccess = new DataTree<GH_ParamAccess>();
var outputs = new DataTree<string>();
var outAccess = new DataTree<GH_ParamAccess>();
var objectProxies = Grasshopper.Instances.ComponentServer.ObjectProxies;
for(var i = 0; i < objectProxies.Count; i++)
{
var proxy = objectProxies[i];
ids.Add(proxy.Guid);
names.Add(proxy.Desc.Name);
var obj = proxy.CreateInstance();
if (!(obj is GH_Component)) continue;
var comp = (GH_Component) obj;
foreach(var input in comp.Params.Input)
{
inputs.Add(input.Name, new GH_Path(i));
inAccess.Add(input.Access, new GH_Path(i));
}
foreach(var output in comp.Params.Output)
{
outputs.Add(output.Name, new GH_Path(i));
outAccess.Add(output.Access, new GH_Path(i));
}
}
Guids = ids;
Names = names;
Inputs = inputs;
Outputs = outputs;
InAccess = inAccess;
OutAccess = outAccess;
}
Is there also a method to retrieve the tab (the group of components) name that a component belongs to?
There should exist something like this: proxy.Desc.TabName
What if I wanna get the information of on specific C# component only, rether than evey component I have. Like I had some codes in the C# component, i wanna get the input and output. I tried to change the line “var objectProxies = Grasshopper.Instances.ComponentServer.ObjectProxies;” but haven’t find a good way.
Awsome ! Could you tell me where can I find the “GrasshopperDocument” namespace/Method ? Seems that it is not in the RhinoCommon API Site. I want to dive into your code and learn how it actually works.
Also, the data type is generic data rether than any specific type (Curve, Line, etc.) This works on general components, but not good for C# components…