Open and run Grasshopper from a Batch file


(Tmanuel Inumlab) #1

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.


#2

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.


#3

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


(Tmanuel Inumlab) #4

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??


#5

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


(Tmanuel Inumlab) #6

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.


#7

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


(Tmanuel Inumlab) #8

Hello!

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


(Tmanuel Inumlab) #9

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!


#10

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


(Tmanuel Inumlab) #11

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…


#12

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…