IronPython code not working in new component

Hello All,

I have a GH script from Rhino 6 with lots of Python components in it. I’m currently converting the file to GH for Rhino 8, which loads the original python components labeled ‘OLD’. The script runs fine with the old components, but I wanna update it to the new components.

I’ve been replacing the old Python components with new ‘Iron Python 2 Script’ components. I copy the inputs and outputs, then copy/paste the code from the old to the new. Some of these components won’t work after copying the old code; they either crash Rhino, take MUCH longer to compute, or just don’t compute the data with empty outputs.

My question is: why wouldn’t code from the old Python components work in the new ones? They both run IronPython, so the language should be the same, no? I’ve checked online but can’t find out what the difference can be. What am I missing?

Thanks in advance for any help.

@Christopher_Botham It definitely should run the same as before especially if you are using the IronPython component.

I would appreciate if you can post a one or two examples of scripts which do not work so I can debug and help better.

Thanks Ehsan for the reply. I tried to simplify the file to upload an example, but it’s too large and complex, and it relies on folder structures on my computer and external Python scripts to run.

I am using the new IronPython component. It seems to treat input lists differently. When I input a Grasshopper list and enable ‘List Access’, the old component would just read it as a Python list, while the new component reads it as a ‘ListObject’, which I can’t work with in the same way as I did before.

For example, if I input a list of dictionaries, I need to reference them as 'list_name[“key_name”], but this kicks back an error that says ‘Expected Int, got Str.’

Do I need to convert all my input lists to another format?

@Christopher_Botham No you should not have to. The end goal here is for the IronPython component to be as close as it can be to the ‘legacy’ one.

I ran a few tests and I can confirm IronPython is getting dotnet types e.g. List[object] instead of Python list. I have logged this to be fixed in this ticket and will look at it first thing tomorrow.

RH-82019 IronPython is getting dotnet types instead of python types

ironpyton_lists.gh (11.8 KB)

3 Likes

@eirannejad thank you so much for this. It will save me lots of work having to re-write the code to match the new component.

1 Like

Absolutely. It’s something I messed up and I’ll fix it :smiley: I’ll update you when the fix is out

RH-82019 is fixed in Rhino 8 Service Release 8 Release Candidate 3.