Automating Rhino

Hello, I’ve recently been looking at automating Rhino operations in order to assist in automated testing of our Rhino plugin.

I was wondering if there is a recommended way to inspect the internal state of Rhino? Ideally I’d like to do things like “Get list of loaded plugins”, “send command”, etc.

I see that there is a large resource of application APIs in RhinoCommon Python docs (this is available via IronPython, right?) Rhino - RhinoScriptSyntax

Are there any samples about exposing some external interface (command interface, simple REST API, etc) to at least call the RhinoCommon API from outside the Rhino context? If not, do I get at least full access to the host filesystem from within Rhino’s Python (so I could json.dump() some results of tests for example).

Thanks! I’m new to Rhino but the amount of flexibility looks incredible so far.

Hi @nv_matt,

With Rhino 6 and early, you options are limited to access Rhino via ActiveX automation (e.g. COM) using the Rhino and RhinoScript objects. The RhinoScript help file contains some information on external access, and the developer samples repo in GitHub has a sample or two that can help you get started.

With Rhino 7, you can now run Rhino inside of other application. For example, you might write a console application that instantiates Rhino and does “something”, such as “Get list of loaded plugins”, “send command”, etc.

Hope this helps.

– Dale

Hi @dale,

This helps, I had found that automation example but was unsure if it was the canonical example on what is available. Rhino 7 will be fun when I can focus on that :slight_smile:

Thanks for the confirmation.

Matt

Hi Dale,

External access to Rhino would be very interesting.

Unfortunately, the link to your GitHub example “console application” doesn’t work anymore:
https://github.com/mcneel/rhino.inside/tree/master/ConsoleApps” seems to be broken.

Did you move the code to another location? Would it be possible for you to provide a new link?

Thanks a lot

Thomas

Hi @Thomas_Irnich,

Try this:

with is part of this repo:

– Dale

Hi Dale,

I have looked at these applications in the past, but they do not help me.

I have also read and tried other posts that based their solutions on CreateObject and GetObject and Rhino scripts.

However, I have not been able to start Rhino from an external application and draw a line in it, for example with RhinoDoc.Objects.AddLine(Line).

Probably only a few lines of code are missing here to ‘connect’ RhinoCore, RhinoApp and RhinoDoc.

Thomas

Hi @Thomas_Irnich,

This relates to ActiveX automation (e.g. COM) and access to the legacy RhinoScript object. Probably not what you want.

– Dale

Hi Dale,

Yes, indeed ActiveX Automation is probably not the right approach.

But what would be the right approach?

How do I get an external application to start Rhino (or access a running application) and then draw a line in it?

Should I better post my question in another section of the forum?

Thomas

Hi Thomas,

You can open Rhino.exe with arguments passing a script to run for example. See here:

HTH
-Willem

Hi Willem,

Yes, you could draw a line by starting Rhino with arguments to run a script. However, in this case, that is not practical, as a script is far too slow and cumbersome for my purposes.

Instead, I want to create a geometry using the methods of ‘Rhino.Inside’. A simple example is RhinoDoc.Objects.AddLine(Line). This way, even complicated geometries can be created quickly and clearly. Today I already succeed in doing this and I can save the geometry e.g. in 3dm format. However, I am not yet able to create and display the geometry in a running instance of Rhino. There is probably only one small step missing for this, but I don’t see it yet …

Thomas

1 Like