Using rhinoinside with python

Hi,

I have installed Rhino 7 WIP and rhinoinside using pip install.
The first time I try to run the sample script shown on github I get the following error:

“FileNotFoundException: Unable to find assembly ‘RhinoCommon’.
at Python.Runtime.CLRModule.AddReference(String name)”

The second time I try to run the same script I get:

“ModuleNotFoundError: No module named ‘Rhino’”

Any ideas on what is causing this and how to fix it?

RhinoInside is probably not doing a good job of finding the Rhino 7 WIP on your computer. Where is Rhino 7 installed? I’m looking for the full path to rhino.exe

I have installed Rhino 7 WIP on this path:
“C:\Program Files\Rhino 7 WIP”
I have tried to give the path explicitly.

import os
import rhinoinside
rhinoinside.load(os.path.join(os.environ[“ProgramFiles”], “Rhino 7 WIP”, “System”))
import System
import Rhino

The same error message still appears.

I just published a new version of the rhinoinside package (0.5.0) to pypi.org. Try installing this new version to see if it works.

Steve,

What are the current limitations of the python version? I am assuming that the .net versions are further along than the python implementation.

thanks,

joel

Hi guys,

I was experiencing the same problem.
Solved it using pathlib module (available in python 3).
The example below works for me:

from pathlib import Path
folder = Path("C:/Program Files/Rhino 7 WIP/System")

import rhinoinside
rhinoinside.load(str(folder))

import System
import Rhino

Best,
Rui

2 Likes

This shouldn’t be necessary. Are you using the latest version of the rhinoinside package?

Yes (version 0.5.0).
Downloaded it again this morning just to be sure.

Hi @RdK
I’m having the exact issue in Jupyter Notebook and I used the exact code you used to fix it. However it still returns this error:

I wonder what inspired you to implement this code? I am trying to identify the root cause on my end.

I also have this problem and not sure how to solve it.

following this -

in cmd this works

pip install rhino
git clone https://github.com/trendels/rhino.git
cd rhino
python setup.py install

now this doesn’t work

pip install -r requirements.txt
make test

After that I just copied the codes in the pypi but it doesn’t work

from rhino import Mapper, get

@get
def hello(request):
    return "Hello, world!"

app = Mapper()
app.add('/', hello)
app.start_server()

After that, I tried this and it works if I run the vscode in admin mode. (it didn’t work without it)

import rhinoinside
rhinoinside.load()
import System
import Rhino

# for now, you need to explicitly use floating point
# numbers in Point3d constructor
pts = System.Collections.Generic.List[Rhino.Geometry.Point3d]()
pts.Add(Rhino.Geometry.Point3d(0.0,0.0,0.0))
pts.Add(Rhino.Geometry.Point3d(1.0,0.0,0.0))
pts.Add(Rhino.Geometry.Point3d(1.5,2.0,0.0))

crv = Rhino.Geometry.Curve.CreateInterpolatedCurve(pts,3)
print (crv.GetLength())

Screenshot 2021-09-20 044613

The rhino package on pypi is not developed by McNeel and has nothing to do with the Rhino that this forum discusses. This is a separate package created by someone else.

Oh, now I read why it said RESTful web services… should have looked more carefully…

Anybody have any luck using Rhino Inside with Python 3.10?

That won’t work yet. 3.8 is the current highest version we can support. We need to wait until pythonnet library has been updated to support newer versions of python