How to open a Rhino file in another Gh file (both should work together)

Hello everybody,

I have a question regarding opening a gh file from another gh canvas. I can open a gh file in another gh canvas. But, I can’t compute both of them simultaneously. When I open a gh file in a canvas with python, it is opened in the same rhino file. I think, I should create a new Rhino document inside of canvas and open the gh file in this Rhino document. Do you know, how can I do it?

Hello. Why do you want to do this? Is your objective to solve them in parallel? If so, you could try Hops: Rhino - What is Hops

Hi Luis,

thank you for your response. Yes, I need to solve 4 file in parallel. I thought about hops. But, we can’t afford hops (core billing because of using windows server) at the moment. I developed a component for my case. It works well. But, I need to open these 4 files in batch mode simultaneously. I can open these files in grasshopper sequently or with python outside in the same time. It doesn’t matter. However, I could open only one file until now. Do you have any suggestion?

Hops can run locally on your computer without incurring any additional cost. Check out how to get started: Rhino - What is Hops

if you use windows server, you have to have core-billing licence. I spoke Andy before about it and I think I don’t need so sophisticated component. I should only be able to open 4 different files in parallel. Therefore, I would be appreciated, if you help me with python code :slight_smile:

Not sure if we are understanding each other. You want to solve 4 definitions at the same time, on your computer right? You don’t need windows server for this. Just get the Hops component from the package manager, and restart Rhino / GH. This will run a Rhino.Compute instance on your computer (running Windows Desktop OS), and the Hops component will use that to solve the other definitions in parallel. No Windows Server or core-hour billing needed.

If you want to solve these 4 different files remotely, then yes, that is when you might need Windows Server and core-hour billing.

Maybe take a look at the “Read 3dm file” component in the Human plugin. It allows you to import objects from external files. Not sure if you need to edit the files or just read the objects. If you use this method you can operate on the data simultaneously using data-trees:

An alternate way if you´re okay running the files SEQUENTIALY, could be to run something like the commands below through a function like this (C#):

Rhino.RhinoApp.RunScript("command", true);

Commands (use format and replace the {0} input with your file locations).
-Open No “{0}” _Enter _Enter
-Save _Enter

The last one is quite finicky to get working depending on the complexity of your processing.

I’m using a workstation, which has windows server. I can’t change it (the decision is not from me). In addition, it would be also better, when I solve these files remotely. My system works well apart from openning files now. I need only to open four files simultaneously.

I don’t have a problem to import or export the objects. But, I’m trying to solve the files remotely. For that reason, I need to open 4 different files simultaneously. Then, my code can solve the files correctly.

Therefore, “Read 3dm file” can’t help in my case, I think. I wrote the following code. If I run this code outside from Rhino, it opens one GH-File. However, a for loop doesn’t work(of course with appropriate change in the code). The code changes only current GH-File, not opening four files in parallel. If I run this code inside of canvas, the code changes the current canvas.

import rhinoscriptsyntax as rs
import clr
clr.AddReferenceByName(“Grasshopper”)

import System
import Rhino
import Grasshopper
from Rhino import RhinoApp, RhinoDoc
from Rhino.Geometry import *
import rhinoscript as rs
import os

import scriptcontext
if Bool:
cmd="-SetWorkingFolder “+”"“+os.getcwd()+”""
rs.application.Command(cmd)
rs.application.Command("
-SaveAs " + “delete.3dm”)
gh = RhinoApp.GetPlugInObject(“Grasshopper”)
gh.LoadEditor()
gh.ShowEditor()
gh.OpenDocument(Filename)
out = True

Hopefully, I could explain, what I really need. Thank you for your help :slight_smile:

Thanks. That is an important detail which you hadn’t clarified. I guess you already know our licensing policy for Windows Server.

I’m not entirely sure about the topology of what your trying to archive, in terms of what runs first and all that. But that being said Rhino is a single monolithic application if your running your Python code from within Rhino, so For Loops are sequential by design. I think @fraguada’s solution of using hops for this might be the only way to archive your goal of concurrent computing all GH files in parallel. You can limit the number of Child Processes it spins up to 1 but at that point your calculating in sequence again.