Differences between Python3 and Python 2 in Rhino 8 Beta

I am wondering if anyone knows why the rhinocommon library is processed differently between the Python 3 and Python script environments?

Is rhinocommon being re-written for Python 3?

Thanks for any clarity.

Does this help?

1 Like

Thanks, but not really.

I am just wondering what the differences are between Python 3 implementation and Python 2, as far as Rhinocommon goes. Is it just, read the docs and figure it out? Or, is there a reference to changes being made from v7 to v8?

Best

@robertjasoncross

Using RhinoCommon functionality should be virutally indentical in both Python 3 and Python 2. We are in the process of updating the documentation just in case there are any differences. You should be able to copy/paste your exising python 2 code into a new script component with minor changes mostly related to differences in python versions e.g. print is a function in python 3, or some standard libraries names have changed.

On the implementation side, and internally however, Python 3 and 2 are VERY different.

Let me know if you have specific questions in any of these areas.

The error that you shared seems to be a bug. I have logged it here, and will get that fixed

RH-77315 Point3d is missing .Clone() in python 3

I am just trying to understand the issues as shown in the image above. Same code, p3 throws an error, Py2 does not. I have no problem understanding Python 2 and 3 context and the script component, etc. I am just wondering why the two are responding differently. Is there a different way we are supposed to clone points in py3/rhino8?

Thanks.

Okay this is an odd one. .Clone() is an explicit method on Point3d and hence you will not be able to call it directly in C# or Python 3. I’m not sure why IronPython allows doing that but then again IronPython did a lot of sketchy things.

This will do the job for now. I’ll continue inspecting this and see what I can do

in Python 3

import System

System.IClonable.Clone(origin)

In C#

using System;

clone = ((System.ICloneable)origin).Clone();

Thanks for the help.
That threw another error. I guess I will just have to solve it with code changes.

Thanks again.

Well, Point3d is IClonable so that is a bit of a gray area on how python implementations decide to interpret interfaces. I would recommend using the copy constructor in both Py2 and Py3

import Rhino.Geometry as rg
clone = rg.Point3d(origin)
2 Likes

Are you running the netcore or netframework Rhino? If you haven’t played with settings it’s probably netcore. I’m not getting this error on my machine but till test.

Not sure of the difference. I have only installed the beta as default

1 Like

@robertjasoncross Ok. I’d follow Steve’s advice above and use the copy constructor.

1 Like