Tell running Rhino application to execute script

I wouldn’t jump to that conclusion :smile:. It’s just a matter of getting someone who knows about this to answer.
Perhaps @dale can provide a pointer?

I think you can make it automaticly with python or rhinoscript so you only have to click one button.

The problem is that everything should work completely automated, without pushing any button, so after a new IGES or 3dm file has arrived, my pythonscript should trigger and process the data.

Ok, if there is really no way to use Rhino as some server for my requests, I will have to stick with that.

You have not understood what @jordy1989 thinks…
Programing/Run Your script as loop and not close Rhino
Automatic Startup Your script in Rhino…

Which system do you work 32 or 64 bit ?

I think I did understand what jordy meant, that’s why i wrote “i will have to stick with that” :smile:
I just thought it would be more elegant to start the script only when needed and not looping all day long (or checking for new data after some sleep)

I have a 64bit system

I remember it used to be possible, here how it was up to Rhino 4:

http://wiki.mcneel.com/developer/automation

Is this dead?

If you create a windows application you can use this yes.
It is not for python scripting because you still have an eternal loop then.

Not, is not dead, i’m use this external ACX access. (That’s a very good interface in Rhino)

  1. Download and install from here: AutoIt Downloads - AutoIt

Download attached file ArrivedFiles.zip (1.0 KB) ArrivedFiles.zip (979 Bytes) ArrivedFiles.zip

2.Install Autoit → Scite with option Edit Script !!! !!! not Run Script

3.On your desktop create directory named IGS_Files

4.Put there few IGS files (For first test small files !!!)

5.Start Rhino

  1. Unzip ArrivedFiles.zip, open Scite Editor and load extracted file ArrivedFiles.au3 (Source code)

  2. Press F5 or run script from scite menu → Tools → Go

What happens ?
External program is started
Every 20 minutes is checked whether new files arrived in folder IGS_Files
Files older than 20 minutes are ignored !!!
If new file arrived, command is executed, in my example, command Import IGS is used
If sixteen(16) clock is reached, script quit automatically
Exit script manual with RMB over Icon in systray

If everything works test your script
Give your script a command alias and change line like this

$r.Command("YourAlias", False)

Edit:
Or Pythonscript: Make that Your Pythonscript is on search patch and add this as command

$r.Command("-_RunPythonScript (Samples.MyPythonScript.py)")  ;;;Not tested

At the end of your script → do not forget to delete all objects from document !!!

If everything works
You can compile this script as exe file. Ctrl + F7 or menu → Tools → Compile

Do not use Obfuscator ore UPX, otherwise your antivirus program will explode

Finally,
use at your own risk, I do not give liability

Quick tested in Rhino4,
I do not know if LastCommandResult() returns a value when used aliased script

So finito end midday meal…

Wow, thanks a lot for this detailed description!!!

I will try it out as soon as possible.

First sorry for my bad English. (Google translater is my friend)

OK,
Here was a little logical bug
I have added two more lines
ArrivedFiles.zip (1.0 KB)
New:
First loop import file that are no older than 20 minutes.
(But “DAY” is not checked, so remove files from previous day)
Next loop imports file that are no older than 20 minutes + Running time from previous loops.
After all loop’s finished, rhino.interface is destroyed, script will pause’s for 20 minutes.
After pause, for next loop new reference to running Rhino will be created, but in this case not ideal.

I have new modified old script, in this case, the object will accessed remain permanently in one same Rhino process.
ArrivedFiles_1.zip (1.0 KB)

Rhino can be automated, externally using ActiveX.

http://4.rhino3d.com/5/rhinoscript/introduction/external_access.htm

Here are a couple of examples that demonstrate this using VBScript.

https://github.com/mcneel/rhinoscript/blob/master/TestRhino5Automation.vbs
https://github.com/mcneel/rhinoscript/blob/master/BatchRender.vbs
https://github.com/mcneel/rhinoscript/blob/master/RhinoRender.vbs]

I don’t know if standalone Python supports ActiveX. But using VBScript, you can launch Rhino and have it run a Rhino.Python script.

Hi Dale, I was trying this automation example: https://github.com/dalefugier/SampleCsAutomation
When trying to create an instance of Rhino it hangs. Task Manager is showing the process Rhino.exe, but from the description it appears to be the WIP. After some time it gives up trying. Do you have an idea how to get it to work?

Thanks,
Jess

Well the command is trying to create a Rhino5x64.Application object and (from your screen capture) Rhino 6 is loading which is a problem. Looks like the WIP installer is hosing COM entries in the Registry that were added by the Rhino 5 installer.

http://mcneel.myjetbrains.com/youtrack/issue/RH-31297

To fix, run REGEDIT and navigate to this key:

HKEY_CLASSES_ROOT\CLSID{D760652E-E256-4064-B308-08CE0711ADF5}\LocalServer32

Modify the entry to point to the Rhino 5 x64 executable.

Thanks Dale!
I was using the interface in the meantime and think I’ll stick with that :wink:
Jess

Hi @dale,

the links above to github seem to be dead. I’ve found The TestRhino5Automation.vbs example via google and changed:

Set objRhino = CreateObject("Rhino5x64.Application")

to:

Set objRhino = CreateObject("Rhino5x64.Interface")

My Rhino 5 x64 SR12 is open. If i run the vbs script from a command prompt, it opens Rhino 4 instead, writes the file to the desktop and then hangs. I’ve searched my registry for above key but it does not exist. It also opens a new Rhino 4 when it is already open. How can i change it so it uses the open Rhino 5 x64 instance ?

Here is my vbs: TestRhinoAutomation.zip (840 Bytes)

I’ve seen your zip files on YouTrack but i am unsure which one to use to fix this without goofing things up :slight_smile:

EDIT: I’ve found the Rhino.Interface and Rhino.Interface.6 entries, but get same problem, it pops up a new rhino.exe in taskmanager which does not remain open and ignores the allready opened Rhino5 or Rhino 6 instance.

_
c.

Hi Clement,

I ran the script you reference here and it seems to work. Here the the source, by the way.

https://github.com/mcneel/rhino-developer-samples/blob/5/rhinoscript/TestRhino5Automation.vbs

If you’ve grepped the Registry cannot find either Rhino5x64.Application or Rhino5x64.Interface then you should probably repair your installation, as these keys are added by the Rhino installer.

Note, Rhino.Interface and Rhino.Interface.6 are for Rhino 6.

– Dale

1 Like

Hi @dale, i guess the problem is my registry, the Rhino5x64.Interface is missing:

I can make it work for an open Rhino4 instance by using: Rhino4.Interface, it works for an open Rhino5 x86 instance by using Rhino5.Interface and for Rhino6 x64 by using Rhino.Interface.6

How can i repair my registry or add the missing keys without too much risk loosing my configuration ?

thanks,
c.

Hi Clement,

Try right-clicking on your Rhino shortcut and then pick “Run as administrator.” Does that help?

– Dale

Hi Dale, unfortunately not.

I’ve now solved it by creating an ironpython script which i can run with ipy.exe using the clsid 4AD5D33E-7576-4C71-BEDC-E174E5DEF0DA instead of Rhino5x64.Interface:

import System
guid = System.Guid('4AD5D33E-7576-4C71-BEDC-E174E5DEF0DA')
xType = System.Type.GetTypeFromCLSID(guid)
obj = System.Activator.CreateInstance(xType)

This works when Rhino5x64 is open. For Rhino4, Rhino5 x86 and Rhino 6 it seems to accept a ProgID:

xType = System.Type.GetTypeFromProgID('Rhino4.Interface')
xType = System.Type.GetTypeFromProgID('Rhino5.Interface')
xType = System.Type.GetTypeFromProgID('Rhino.Interface.6')

…but not Rhino 5x64. Strange.

_
c.

1 Like