I would stay away from tree input and output if you don’t need it. We haven’t done a whole lot of work in this area and it is pretty infrequent when you actually need to work with a tree in your function.
Do you really need a tree for input to your function? It’s pretty rare even in core grasshopper components for this.
I wouldn’t say it’s too rare, at least not for my daily workflow. For instance, if I’m trying to bring many many vectors of n-dimensions, I would put each of them into a list an pass it as such.
How would you pass a nested list from GH to CPython through Hops instead? Is there any other object that can handle this transaction?
I knew I was going to get flack for writing that. I should just resolve to writing nothing but bug reports here. I asked a question and provided a fact about core grasshopper, nothing more.
I understand that there is a need for tree input, but the majority of core components in grasshopper are item or list input and allow grasshopper to perform the iteration when trees are provided as input.
@dadandroid the Hops component doesn’t actually support tree parameter access on the inputs. The component should be defaulting to list access and may well be throwing an error because the first list is empty (assuming you’re using the default inputs for the Series components). Strangely on my Mac I get a warning instead of an error.
That form calls the python server with one item at a time and then relies on GH to construct the output tree. David is looking to get at the whole tree at once.
FWIW I got around this by serializing the nested list into a json formated string and back, which seems to work since it’s a nested lists of integers. Probably won’t be so easy for other types, though
@Hamilton_Forsythe what you can do is output a (flattened) list of geometries in one hops output, and the list lengths in another to rebuild the tree structure in Grasshopper.
It’s a workaround I’ve been using as well, but it becomes more tedious when the desired tree output should have more than one branch level.
Imagine now that the desired tree output could have different branching level depending on the inputs… yikes !
I’m wondering if hops is intentionally left to die for the new python3 in rhino8…
I wouldn’t be against it, as I would not be against a statement from the devs either
Hi @dadandroid, I met the same issue.
Can’t image that hops has such a problem of handling data tree…
Could you please be more specific on your method of JSON format?
Thanks!
Hi @dadandroid,
I don’t think the problem is settled down.
In the example, after the tree of number is imported in hops, the type of the data is not ‘list’, but ‘float’.
That means you can’t take out each item in the each for further processing.