Rhino inside Python

No, for this we will need to be able to embed the CPython runtime in Rhino itself. This is a project that we are working on for Rhino 8.

3 Likes

Very nice , this will be useful and solve many problems with python modules.
I tried this and i will open separated topic to understand better how to send only one point.

image

I don’t know if this work or what i miss here

Hello @stevebaer
As you see i try this and it work fine without rhinoinside.
Now is it possible to send data from Grasshopper to Ansys directly?

In Ansys ironpython all Rhino commands available but there is a problem with some geometries, but actually it is not important because i only nee send and receive data.

Hi @stevebaer, I keep running into this. I have Rhino 7 installed and I think it fails to import Rhino.

PS C:\Users\user\Desktop\rhinoinsidepython> & C:/Users/user/AppData/Local/Programs/Python/Python37/python.exe c:/Users/userh/Desktop/rhinoinsidepython/rhinoinsideppython.py

Traceback (most recent call last):

File “c:/Users/user/Desktop/rhinoinsidepython/rhinoinsideppython.py”, line 2, in
rhinoinside.load()
File “C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\rhinoinside_init_.py”, line 39, in load
clr.AddReference(“RhinoCommon”)
System.IO.FileNotFoundException: Unable to find assembly ‘RhinoCommon’.
at Python.Runtime.CLRModule.AddReference(String name)
PS C:\Users\user\Desktop\rhinoinsidepython>

Hi @stevebaer, any update on this? It fails to import ‘System’.

I just pushed a new version of rhinoinside for cpython to pypi. Try installing this version to see if if fixes the issue you are seeing

1 Like

When
pip install --user rhinoinside
I got
error: option --single-version-externally-managed not recognized.
To fix this

pip install -U setuptools
pip install -U wheel
2 Likes

I am having trouble with the rhinoinside · PyPI download. I will keep trying, any online tutorials or instructions for pip install rhinoinside?

Are you using python 3.7? Later versions of python may not be supported

1 Like

I should have catch that, I am running 3.10 python, I remember that I must use python 3.7 now that you mention it. My learning curve is steep but I am trying to catchup to the hops video workshops last year. Trying to bring all my work from ghpython remote into the ghhops_server and python 3.0 before school starts back up in the fall. thank you for all you are doing at McNeels.

The idea of teaching predictive modeling after bringing parametric modeling to my digital sculpture electives really appeals to me! I need those python libraries working!!!

All the Best, Michael Wickerson

Amazing development as always @stevebaer! Thanks!
I got your sample code working fine for a first time/run, but when I’m trying to run the script for a second time (I’m working in the Anaconda Spyder environment) it crashes with a fatal error on the rhinoinside.load() line:

COMException: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at Rhino.Runtime.InProcess.RhinoCore..ctor(String[] args, WindowStyle windowStyle, IntPtr hostWnd)

My guess is that the instance of Rhino.Inside is already live and the .load() is not required anymore and we need to connect to that one - or simply skip the line altogether. Is there a flag available somewhere to check if Rhino.Inside is live already? something in the line of:

if not rhinoinside.islive:
rhinoinside.load()

Thanks! :slight_smile:

It is probably something else as we perform this check internally. I’m not familiar with the Anaconda Spyder environment and what makes it unique.

ah I see. yes, that makes sense to do indeed :slight_smile:
Thanks for being prepared already!

Ok, let me try another environment like VS Code and see if that resolves the issue (and then I just need to check why Spyder does that stuff… haha)

indeed… no problem at all running the code twice in VS Code…
I guess there’s my answer. Sorry for the bother!

Hi, 1st off thanks for the incredible push in development for coding within the Rhino environment!
I’m trying to wrap my head around the entire toolset, as we were working with Hops for geometric solutions until now but we do need to start using CPython for larger computational tasks still involving Rhino geometry at the beginning of the process.

It is my understanding that Hops uses Rhino3dm, whilst Rhino Inside uses RhinoCommon (which all of out GHPython components are using). I want to use RhinoCommon in CPython (meaning rhino.inside has to be used), but then I can’t use Hops to use GH geometry as inputs.

How then should I import geometry into the CPython definition to be able to use RhinoCommon?
Did I get the whole thing wrong?

Thanks in advance,
Lev

Hi Lev,
Sorry for the delayed reply. Could you provide a little more information on what you are hoping to do? Hops uses geometry defined in both rhino3dm and RhinoCommon and it just depends on what you are trying to accomplish.

Hi! I’m wondering if there’s any update on accessing Grasshopper features from cPython via Rhino Inside? I’m not quite sure what my options are at the moment to achieve this- whether I can use rhino inside or rhino compute is still the only option.

You can access grasshopper from CPython via Rhino.Inside. I would need a better idea of what it is you are trying to specifically do to be any more helpful.

1 Like

Oh! Wonderful! I’m trying to assess whether Rhino Inside via cPython is suitable for a research project I’m currently working on- is there any documentation to get started with grasshopper in cPython? I got Rhino set up easily, but couldn’t find anything on grasshopper. I’ll probably have a more defined set of questions afterwards once I start experimenting with it.

1 Like

I ended up finding some documentation from waaaay before about triggering GH from RS in Python- is that the starting point still? or is there rhino inside specific documentation nowadays?