Rhino inside Python

5 posts were split to a new topic: Autocompletion with PyCharm

Very exciting!
Now I just need to persuade my company to upgrade to Rhino 6, give me installation priviledges for the WIP, invent a project combining geometry with data wrangling…

1 Like

I just updated the rhinoinside package on PyPi to a new version.

This new version requires that you call a load function immediately after importing rhinoinside

import rhinoinside
rhinoinside.load()
import Rhino

pt = Rhino.Geometry.Point3d(0., 0., 0.)
...
2 Likes

Hi @stevebaer,

This seems interesting.

Should we consider this the beginning of the end of IronPython engine in Rhino?

Having mixed feelings because I am still getting comfortable using IronPython with RhinoCommon API. I feel it’s either going to become easier or more difficult to use the api docummentation.

No

This project embeds Rhino inside the python process. Our use of IronPython is to embed a python interpreter inside the Rhino process. Even if we added a different embedded python interpreter in Rhino, we still wouldn’t need to drop the IronPython engine.

The syntax be the same so there is nothing different to learn.

4 Likes

7 posts were split to a new topic: Embed Different Python Engine

I just updated the Rhino Inside python library on PyPi.org to 0.3.0. This version now supports Python 3.7

If you already have rhinoinside installed, you can upgrade with the following command
pip install --upgrade --user rhinoinside

4 Likes

This is huge news! The Rhino/Python user/programmer dream to integrate the Cpython vibrant community packages inside the rhino vibrant community tools! By any chance, is there a plan to implemmet Rhino inside Freecad? As an open source project could this implementation be developed by an independent research team?

1 Like

This is really exciting! I’m playing with it now.

Is there a way to import Grasshopper plugins, or is it limited to Rhino?

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.

1 Like

@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:

@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.