Transferring data between Python components

I am having trouble understanding how I am supposed to handle inputs/outputs for the Python 3 component in Rhino 8. It’s different to Rhino 7 where Python lists automatically become Grasshopper lists.
Searching around I found that there is a hidden Avoid Marshalling Outputs option (link) although I’m not sure how to also have the python component simultaneously output Grasshopper lists of objects (there are multiple outputs and usually I would be outputting both geometry and Python data).

At the moment I see two suboptimal solutions:

  • Not marshal the outputs but have an additional component to marshal any outputs desired.
  • Wrap the python objects intended to be inputted into other python components in a custom class.

Any better solutions?

Are you sure the mode of the output param is set to list or tree?

Where is this setting? I don’t see it when I right click the outputs or the component.

@YCoCg Would it be possible to share a small example that replicates the problem you are having?

Python 3 parameter marshaling is documented here. Let me know if there is anything missing or is confusing and I can improve:

simple example marshalling 1.gh (16.0 KB)

I am trying to have the same functionality as is provided in Rhino 7, the wrapping method I mentioned and include in the example file seems to be the closest but I’d rather not need a class for this.

Oh sorry - I’m not able to check at the moment. Do you see it on the inputs?

I remember passing dictionaries between Python components, without Grasshopper converting them into a .Net implementation, by returning them inside a list, instead of just as they are.

The second example in my screenshot is basically that, I set the D output in Python to a list of dictionaries. No matter how much I wrap them, all the elements seem to be converted to something other than Python objects, preventing the second python script from reading it directly.

The list wrapping trick does indeed not seem to work with the new CPython editor, however the Grasshopper ObjectWrapper does appears to still do the trick:


241016_CPython_PassDict_00.gh (2.2 KB)

2 Likes

Okay I see where the bug is. Working on a fix ASAP:

RH-84379 CPython marshalling error

@YCoCg Got this issue resolved and put a fix in the next 8.13 SRC (I decided to push this out earlier so you don’t have to manually wrap the outputs in GH_ObjectWrapper.

Also created a unit test to make sure this list_with_dictionaries case is always tested

2 Likes

RH-84379 is fixed in Rhino 8 Service Release 13

1 Like