2

I am currently opening Rhino and running Rhino command lines using subprocess.call() in an external python script.

rhinoPath = "C:\\Program Files (x86)\\Rhinoceros 5\\System\\Rhino4.exe"
rhinoCommandFilePath = "Z:\\Arkangus\\2019\\RhinoCommand.txt"
scriptCall = "_-ReadCommandFile {0}".format(rhinoCommandFilePath)
callScript = '"{0}" /nosplash /runscript="{1}" /runscript="_-Exit"'.format(rhinoPath, scriptCall)
subprocess.call(callScript)

However, it means opening Rhino everytime I am running the script, and closing it after.

Is there a way to check if Rhino is already open and run the RhinoCommand file directly into Rhino if it is the case?

I am not looking for a pipe between Rhino and Python.

Thank you!

4
  • 1
    have you looked here developer.rhino3d.com/guides/rhinopython? Commented Mar 19, 2019 at 10:24
  • 1
    Yes, but if I'm correct rhinopython is to be used within rhino. I was probably not clear enough, I want to run the python script externally from Rhino. Commented Mar 19, 2019 at 10:30
  • Have you seen github.com/mcneel/rhino.inside/tree/master/CPython? It might help. Commented Apr 17, 2019 at 11:58
  • I had not, thanks for the link! I will take a look. I found compute_rhino3d and rhino3dm meanwhile though, will update my answer accordingly. Commented Apr 25, 2019 at 8:43

1 Answer 1

1

To check if Rhino is already open (Note: this is only a partial answer to my issue):

Checking if program is running programatically

import psutil

def is_rhino_open():
    for pid in psutil.pids():
        p = psutil.Process(pid)
        if p.name() == "Rhino5.exe":
            print ("Rhino5 is running!")

Other way: use Rhino's compute functions directly from within Python (no need to open Rhino) with the CPython3.x modules rhino3dm and compute_rhino3d.

https://discourse.mcneel.com/t/run-script-from-windows-command-prompt-with-open-rhino/80736/2?u=gabriel.taquet

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.