Am I the only one who got confused using ghpythonlib.components?

I think I’m not getting ghpythonlib.components syntax correctly.
Here are three cases where I can’t get a correct result.

  1. How do I feed options into component in python script like I would do with gui components by right clicking middle of the component body? Tried different kwargs but seems it doesn’t accept any of them.

  2. How can I append number of outputs and inputs in ghpythonlib.components? Components inside the script throws error that there are more outputs than component has.

  3. How do I get result as I would get with gui component? For example here is a script I’ve been writing. With gui component the value of quad_tree[1] would be tree with 3658(number of quad_tree[0]) branches. So I expected to get list of lists as a result - which I didn’t. Does ghpythonlib.components only return ‘flattened-like’ result? If not how do I get tree-like list of lists. Or if so how do I retrive length of result segments(length of branches) with which I would then slice the flattened result?

I do understand intermediate python syntax but am I not? Am I missing something?
Please help me!!!

Hi @grasshoppertrainer,

You are asking advanced questions. Let’s have a look together.

This is not possible. There is no SDK method to do this, so no library can replicate this. The right-click behavior is defined per-component, so there is no way to repeat it automatically at present. @DavidRutten said he would study some options for GH2.

These components are very special, and they are usually a way to represent a looping or conditional construct. The library does not allow to add arguments at present.

The old version of the library, version 1.0 for Rhino 5, did not allow this at all, so you are correct about Rhino 5. In newer Rhino 6 SRs, you can do that with the .tree. version of components. See:

Finally, a word of caution. The more advanced the topics you will explore, the more hindered a fully-functional library that exposes an underlying graphic library might become. The purpose of the ghpythonlib library is to allow people who only used GH definitions, to automate tasks such as a for loop or a while loop in Python, thereby allowing some more advanced interactions. Another purpose is also to automate some plug-ins that have no SDK. If your goals are much more cutting-edge, you might want to use rhinoscriptsyntax or RhinoCommon. All of Grasshopper is written via RhinoCommon.


Thank you so much for teaching! Most of my distress is resolved now.

1 Like