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.
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")
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#.