Launch (another) Rhino using RhinoCommon

Hi,
is there a way to open another Rhino on a button click from a Rhino Plugin?. I already have the 3dm file path, I just need to be able to launch Rhino and open that file…using RhinoCommon and C#.

I am aware of this example but I am not sure how to get it to work…not sure what the rhinoID for Rhino 7 is, and it gives me some errors regarding the “dynamic rhino” variable.

Thanks
Milos

Hi Milos,

i’ve used below in Rhino 6 and 7 (Windows). If you pass a valid Rhino file_name to the function it opens the file. If you run it without a file_name it will just open a new Rhino. The Rhino version is the same which this script is run from.

import Rhino
import System

def OpenFileInNewRhino(file_path=None):
    
    folder = Rhino.ApplicationSettings.FileSettings.ExecutableFolder
    exe_path = System.IO.Path.Combine(folder, "Rhino.exe")
    if System.IO.File.Exists(exe_path):
        if not file_path:
            # opens a new Rhino
            cmd = "! _Run {}".format(chr(34) + exe_path + chr(34))
            rs.Command(cmd, True)
        else:
            if System.IO.File.Exists(file_path):
                # opens a file in a new Rhino
                cmd = "! _Run {}".format(chr(34) + exe_path + " " + file_path + chr(34))
                rs.Command(cmd, True)

if __name__=="__main__":
    OpenFileInNewRhino(r"D:\Temp\Box.3dm")

does this help ?

_
c.

Hi @clement,

thanks for the help. We are not quite there yet. Through Trial and Error I realized that only

RhinoApp.RunScript “_Run Rhino”;

suffices (no need to search for the Rhino.exe). This will open a new Rhino Instance but not the file. Adding a file path to that script did not work (tried it manually in Rhino as well). (Also doing it like you did, with the Rhino.exe path, did not work). So lets see if someone gives us the proper way to do it in C#.

Hi Milos,

if you do not want to control the Rhino exe version, just run the file path of the file to open. Eg. try this in the MacroEditor to test:

_Run "D:\Temp\Box.3dm"

Note that you need to enclose your path in quotes.

Well, i’m using this in a button since 4 years to open a fresh new file (template)…so your problem seems to be something different.
_
c.

Hi,

yes…omitting “Rhino” and just using _Run + “filePath” did work.

Thanks.