Rhino.NodeInCode

Hello Everyone,

To find the components that do not show up in the Library I use this method:

var component = Rhino.NodeInCode.Components.FindComponent(“string”);
var componenttFunction = (System.Func<object,object,object>) sort.Delegate;
A = componentFunction(variable,variable);
This method works when the function has only one output. For the components that they have more than one output I get "IronPuthon.Runtime.List " repeated the same number as outputs number.
How can I solve this problem and choose the desired output of chosen component?
Here as an example I tried to call Sort List component. I attach to this text here.

Best,

What do you mean “do not show up in the library”? You mean that they have the same name of other components?
If so, please post the name and we will try to fix it!

This doesn’t work because you are effectively creating a tree. You can use the class DataTree<object> and add the data to it.

Thank you very much for your reply.
By saying they don’t show up in the library, I mean there is no equivalent method to some components in grasshopper in RhinoCommon documentation or even in grasshopper library.
For instance, for the component CircleTanTanTan in grasshopper, the closest method in rhino common documentation is Circle TryFitCircleTTT. But their input requirements are different.

Or the second example can be the component “Curve nearest object” in which there is no method for that in the Rhinocommon documentation.

For the method, you proposed I’m not clearly understood how to do it. Can you please modify the file I’m attaching here (Sort) so I can clearly understand how it works?

Sort.gh (2.2 KB)

private void RunScript(object x, object y, ref object A)
{
  var dt = new DataTree<object>();
  var sort = Rhino.NodeInCode.Components.FindComponent("SortList");
  var sortFunction = (System.Func<object,object,object>) sort.Delegate;
  double[] d = {1,3,5};
  var result = (IList<object>) sortFunction(d, d);
  for(var i = 0; i < result.Count; i++)
    dt.AddRange((IList<object>) result[i], new GH_Path(i));
  A = dt;
}

Sort.gh (3.0 KB)

1 Like
private void RunScript(ref object K, ref object A)
{
  var sort = Rhino.NodeInCode.Components.FindComponent("SortList");
  var sortFunction = (System.Func<object,object,object>) sort.Delegate;
  double[] d = {1,3,5};
  var result = (IList<object>) sortFunction(d, d);
  K = result[0];
  A = result[1];
}

Sort.gh (4.4 KB)

2 Likes