Rhino inside Python

This should be possible at some point in the future. We are still trying to figure out some issues with Grasshopper running in a headless CPython environment.


@ffribeiro – from a quick look, it appears that FreeCAD has both a C++ and Python API, so it may well be possible to implement Rhino.Inside (but only for the 64-bit Windows version). We don’t have any plans to investigate this ourselves right now, but we have plenty of samples to provide any intrepid developer with some ideas and we’re always available to answer questions!

I also thought about playing around with FreeCAD and RhinoInside.

I simply do not have any other software (license or access to API) to develop for.

And there’s also the fact that I do not know where to start. CPP or just CPython?

I don’t know either. It is possible, but not as easy to integrate Rhino.Inside when there is no .NET SDK available.

is it possible to use rhinoinside inside rhino or only outside of rhino.
So i can only use cpython modules outside of rhino but not inside with the grasshopper python editor ?.

I mean if i use your example it works but can this rhino.curve.object be exist in rhino to make it visible?

sorry i am very new to this

Hi, Flokart. I think that what you are trying to achieve is not a rhino inside subprocess. If what you want to do is run a CPython script inside Grasshopper, maybe you can succeed with this plugin:

or this one:

1 Like

@flokart It’s not currently possible to use cpython modules in Rhino/Grasshopper because it uses IronPython (not withstanding the workarounds that @ffribeiro shared). If you run Rhino.Inside CPython then you don’t get the Rhino UI, but all the geometry you create can be written to a 3dm file and viewed in regular Rhino.

Really neat project!
One thing that I’ve been struggling with is using methods from RhinoApp.
For example I’ve tried to use Rhino.RhinoApp.WriteLine("Hello World"), but nothing seems to show up.

However, if I use print(Rhino.RhinoApp.Version) in python I get the expected version: 7.0.20007.12535. Is there something I’m missing to control Rhino from python?

This command writes to the Rhino GUI command-line, not to terminal. Since Rhino inside Pythen runs headless you won’t see anything.

Great news, looking forward on testing this @stevebaer, thanks!

Hi @nathanletwory, perhaps it is a good idea that there is some kind of output redirection, don’t you think? WriteLine and Print are used quite often for debugging. I had to use chrome in headless mode recently and without being able to print something on the terminal I wouldn’t be able to fix my bugs.

Nothing is stopping you from using print that comes with Python…

1 Like

Sorry if this is obvious: So rhinoinside only connects to a headless Rhino?

I very much love the UI of Rhino and all of its functionality, but I also write Python 3 (not iron python friendly) code. Is it possible for rhinoinside to connect to an existing Rhino instance, and interact with the active document?

For the method of using Rhino that I described above this is correct as python is a headless console application controlling and containing Rhino.

This may eventually be possible, but I haven’t figured out how to do this yet.

1 Like

Thanks for your reply, I wonder if other people also have similar needs. At the moment the GH_CPython libraryis not very robust.

Hope you figure this out soon. :muscle:

1 Like

You aren’t alone, many people want python 3 support and many others want CPython support. We know this is an issue, and the technique described in this post is all we can offer for now.


Guys, thank you for your comments, I was very interested in reading them.

really want rhino gui

Hello guys!
First of all, thank you very much for this great implementation!
Im running some tests here to see what I can do, but found myself stuck right now. In this test, Im trying to use the method Curve.ClosestPoint(Point) from Curves class,
but for some reason unkown to me, it does not work.

If I try basically the same code inside Rhino, it works just fine.

Any idea why?


The signature is bool ClosestPoint(Point3d p, out double t). I think the way to call this is:

rc, t = curve.ClosestPoint(pt.Location, 0.0)

where rc will be the return value of the method and t the out value.

1 Like