# Rhino inside Python

**URL:** <https://discourse.mcneel.com/t/rhino-inside-python/78987>\
**Category:** Rhino.Inside\
**Tags:** python\
**Created:** [February 18, 2019, 9:45pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987 "2019-02-18T21:45:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 18, 2019, 9:45pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/1 "2019-02-18T21:45:54Z")

</div>

Here’s a new toy for the python crowd.

> **[Client Challenge](https://pypi.org/project/rhinoinside/)**

You’ll need to have the Rhino 7 WIP installed on Windows.

This allows you to embed and get access to RhinoCommon from inside of CPython.

You must be running a 64-bit version of Python

- You can use either Python 2.7 or Python 3.7

```auto
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())

```

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [February 18, 2019, 10:27pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/2 "2019-02-18T22:27:59Z")

</div>

Hi Steve,

I’m following this with great interest.  
Can you elaborate some more about how this compares to the current ironpython implementation?  
Am I correct that this is unrelated to RhinoCommon in that rhinoinside is a different API with (still) limited methods and classes.  
Or is that a misinterpretation?

Thanks  
-Willem

---

<div class="post-metadata">

**Author:** ![will](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/will/32/479454_2.png) [@will](https://discourse.mcneel.com/u/will)\
**Post date:** [February 18, 2019, 11:03pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/3 "2019-02-18T23:03:04Z")

</div>

We use IronPython to provide Python scripting within Rhino. [Rhino.Inside](https://rhino3d.com/inside) is running Rhino _inside_ other programs and in this case that program is written in CPython (i.e. the original Python implementation). The full RhinoCommon API is available because Rhino itself is running.

Any program using the Rhino.Inside technology will require you to be running on Windows and have Rhino WIP installed and licensed. If you want to use RhinoCommon without running Rhino (i.e. on a non-Windows platform) then you’ll want to check out [rhino3dm](https://github.com/mcneel/rhino3dm). Rhino3dm’s API is limited but you can use [Compute](https://rhino3d.com/compute) to fill in the gaps.

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 18, 2019, 11:03pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/4 "2019-02-18T23:03:44Z")

</div>

Nope, it is the RhinoCommon SDK exposed inside of CPython. To be honest, I just got this to work yesterday and haven’t really run it through any rigorous tests. Was just too excited to let it sit there and felt it needed to be “thrown over the wall”

---

<div class="post-metadata">

**Author:** ![nathancoatney](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathancoatney/32/767339_2.png) [@nathancoatney](https://discourse.mcneel.com/u/nathancoatney)\
**Post date:** [February 19, 2019, 2:07am UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/5 "2019-02-19T02:07:25Z")

</div>

This seems magical. Perhaps I am misreading something. What makes System and Rhino importable to CPython? Looked at **init** and just went further down the rabbit hole with the clr import.

I tried above in 3.6.4 and get exception:

```
Traceback (most recent call last):
  File "...", line 9, in <module>
    pts = System.Collections.List[Rhino.Geometry.Point3d]()
AttributeError: List

```

I tried with and without the pip --user option, not sure if that matters.

Also beware there is a capital H in line 12.

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 19, 2019, 2:11am UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/6 "2019-02-19T02:11:04Z")

</div>

Oops, I forgot to include the `Generic` keyword. I’ll edit the initial post

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 19, 2019, 2:16am UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/7 "2019-02-19T02:16:48Z")

</div>

> [@nathancoatney](#):
>
> This seems magical. Perhaps I am misreading something. What makes System and Rhino importable to CPython? Looked at **init** and just went further down the rabbit hole with the clr import.

Yes, it is a little magical 🙂 This library uses pythonnet to expose .NET to CPython ([http://pythonnet.github.io/](http://pythonnet.github.io/)) plus Rhino 7’s “Rhino.Inside” feature to load Rhino into python’s process.

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 19, 2019, 7:48pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/8 "2019-02-19T19:48:58Z")

</div>

Split this topic on February 19, 2019, 7:48pm UTC

5 posts were split to a new topic: [Autocompletion with PyCharm](https://discourse.mcneel.com/t/autocompletion-with-pycharm/79020)

---

<div class="post-metadata">

**Author:** ![Dancergraham](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dancergraham/32/497397_2.png) [@Dancergraham](https://discourse.mcneel.com/u/Dancergraham)\
**Post date:** [February 19, 2019, 7:22am UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/9 "2019-02-19T07:22:43Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 20, 2019, 5:45pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/10 "2019-02-20T17:45:42Z")

</div>

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

> **[rhinoinside](https://pypi.org/project/rhinoinside/)**
>
> Embed Rhino in CPython

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

```auto
import rhinoinside
rhinoinside.load()
import Rhino

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

```

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [February 20, 2019, 6:57pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/11 "2019-02-20T18:57:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 20, 2019, 7:56pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/12 "2019-02-20T19:56:49Z")

</div>

> [@ivelin.peychev](#):
>
> Should we consider this the beginning of the end of IronPython engine in Rhino?

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.

> [@ivelin.peychev](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 26, 2019, 10:39pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/13 "2019-02-26T22:39:48Z")

</div>

Split this topic on February 26, 2019, 10:39pm UTC

7 posts were split to a new topic: [Embed Different Python Engine](https://discourse.mcneel.com/t/embed-different-python-engine/79380)

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [May 9, 2019, 10:39am UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/14 "2019-05-09T10:39:03Z")

</div>

I just updated the Rhino Inside python library on [PyPi.org](http://PyPi.org) to 0.3.0. This version now supports Python 3.7

> **[rhinoinside](https://pypi.org/project/rhinoinside/)**
>
> Embed Rhino in CPython

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

---

<div class="post-metadata">

**Author:** ![ffribeiro](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ffribeiro/32/510937_2.png) [@ffribeiro](https://discourse.mcneel.com/u/ffribeiro)\
**Post date:** [August 8, 2019, 1:21pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/15 "2019-08-08T13:21:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sean.merrifield](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sean.merrifield/32/188607_2.png) [@sean.merrifield](https://discourse.mcneel.com/u/sean.merrifield)\
**Post date:** [November 21, 2019, 7:49pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/16 "2019-11-21T19:49:19Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [November 21, 2019, 9:22pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/17 "2019-11-21T21:22:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![will](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/will/32/479454_2.png) [@will](https://discourse.mcneel.com/u/will)\
**Post date:** [November 22, 2019, 2:32pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/18 "2019-11-22T14:32:05Z")

</div>

> [@ffribeiro](#):
>
> 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?

@ffribeiro – from a quick look, it appears that [FreeCAD has both a C++ and Python API](https://www.freecadweb.org/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](https://github.com/mcneel/rhino.inside/) to provide any intrepid developer with some ideas and we’re always available to answer questions!

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [November 22, 2019, 3:34pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/19 "2019-11-22T15:34:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [November 22, 2019, 6:05pm UTC](https://discourse.mcneel.com/t/rhino-inside-python/78987/20 "2019-11-22T18:05:36Z")

</div>

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

[Next page](https://discourse.mcneel.com/t/rhino-inside-python/78987.md?page=2)
