Open and run Grasshopper from a Batch file

Hello!

I have an another question, I’d like to run my rhino and grasshopper file from a Batch file, my file Batch is:

@ECHO OFF
cd C:\Users\Calcul-port\Documents\Stage_2019\Rhino\Automatisation_Rhino_Script\Run
“C:\Program Files\Rhinoceros 5.0 (64-bit)\System\rhino.exe” /nosplash /runscript="-grasshopper editor load document open C:\Users\Calcul-port\Documents\Rhino\AutomatisationRhino_Script\Run\Random_Geometry.gh _enter" “C:\Users\Calcul-port\Documents\Rhino\Automatisation_Rhino_Script\Run\Random_Geometry.3dm”

the problem is is that my CMD window doesn’t close after the BAT runs and my files oppening well but empty, I Don’t know why, can you please help me!

And if necessary change some parameters before to run my Batch file, like I have two points from Grasshopper and I’d like to built two sphere from this points and change their parameter like radius or diameter from Batch file and run it, thanks.

Can you please provide files? I’ve used an approach like this (python to launch rhino with args) however there are several limitations.
You can’t use any grasshopper components that send anything to the rhino command line, otherwise that will interrupt your save and close commands.

Of course your grasshopper script needs to automatically bake as well.

1 Like

Hang on,

You aren’t saving!

You need to add save _enter exit _enter
Not in front of a computer now so can’t test it

1 Like

Ok! thanks Harman

But I have a litle problem,
If I modify my enter by save _enter exit _enter
when I am running; my CMD window is closing and rhino, grasshooper closing too!

is it normal??

Hmm. I thought that’s what you wanted. Can you upload minimum necessary files to run this? Eg

  • .bat
  • .3dm
  • .gh

Having a starting version will make it a lot easier for others to help you.

To clarify, is your grasshopper file baking rhino geometry when you open it manually? Without any user interaction?

I assume you have some existing gh files that you want automate, if it is just the points and spheres you could put rhino commands in the runscript argument

Here are mys files:

Random_Geometry.gh (12.9 KB)
Random_Geometry.3dm (38.5 KB)

That’s my program run file:

@ECHO OFF

cd C:\Users\Calcul-port\Documents\Stage_2019\Rhino\Automatisation_Rhino_Script\Run
“C:\Program Files\Rhinoceros 5.0 (64-bit)\System\rhino.exe” /nosplash /runscript="-grasshopper editor load document open C:\Users\Calcul-port\Documents\Stage_2019\Rhino\AutomatisationRhino_Script\Run\Random_Geometry.gh_save _enter" “C:\Users\Calcul-port\Documents\Stage_2019\Rhino\Automatisation_Rhino_Script\Run\Random_Geometry.3dm”

I want automate some existing gh and 3dm files, but I Don’t know how to do it and when I am running my BATCH file the problem is alwais the same, it’s opening and closing alone, I can’t see my geometry or modify it.

Hey,
Have u tried to run the .bat as admin?
If I don’t do so, Rhino starts, at least for me, in the sandbox (Comodo).

I just tried (as admin) and it works fine…
allmost… (I tried to read some files within GH, closing all again fired by a file-change).

Hello!

I’ve tried that’s working but not openning my gh and 3dm geometry files

sphere.gh (7.9 KB)
run_sphere.txt (417 Bytes)
sphere.3dm (21.6 KB)

I have the same problem, My Batch file is working well but Don’t oppening my grasshopper and rhino geomerty!

hm…

Try this…
TEST.zip (40.7 KB)

It works just fine for me…

Currently the .bat asks for a path to work on…

In ur case this would be:

C:\Users\Calculport\Documents\Stage_2019\Rhino\AutomatisationRhino_Script\Run\Random_Geometry

NOTE the missing file-extension!
In this special case the .gh and .3dm have to share a common file-name (Random_Geometry)

EDIT:
I’m on Rhino 6

Ok thank’s it work now!!

And from this file how can I do if I have to control the parameters from Grasshopper like change my radius at the start of Batch file, what kind of scripts can I put in the Batch file??

thanks…

puh…
This one I have not tried from .bat yet.

A good start could be to use the File-Watcher within Grasshopper (Read-File) from whatever format u can parse to data, to feed ur definition with it. (txt, xml, csv, json, …, …)

U may want to write this input-file before OR during an opened Rhino/Grasshopper-session…

1 Like

Hello mark_otler!

I’d like to write this input-file before run my Rhino and Grasshopper file, like take Control of all parameters,

From a Batch file, whrite a script where we could change the Radium, Height and the number of lattices in each direction.

my Batch scrip:

@ECHO OFF

cd C:\Users\Calcul-port\Documents\Stage_2019\Rhino\Automatisation_Rhino_Script\Results

“C:\Program Files\Rhinoceros 5.0 (64-bit)\System\rhino.exe” /nosplash /runscript=“-grasshopper editor load document open C:\Users\Calcul-port\Documents\Stage_2019\Rhino\AutomatisationRhino_Script\Results\essais.gh_save _enter” “C:\Users\Calcul-port\Documents\Stage_2019\Rhino\Automatisation_Rhino_Script\Results\essais.3dm”
exit

my files:

essais.gh (9.2 KB)
essais.3dm (233.4 KB)

Hey, Tmanuel Inumlab

I do not see any try to do so at ur own.
I do not answer on requests like “I have a wish, do it for me”…

As allready said. write a file somewhere and parse it within Grasshopper to get ur data.
Check out the component “Read-File”… U decide which format u use as an input…
The most easy to use, imho, is CSV (= comma-seperated)…

Try ur own, come back with some files and a description of any upcoming problem.

Greets
Mark

3 Likes