Simple BATCH File issue

Hello Everyone,

I am needing a little help sorting this one: would like to trigger a specific Rhino file , from a Batch (*.bat) file, and run a script on that *.3dm file.
I have seen/read here in the forum a few notes about the Rhino and batch files, but nothing seems to solve this one, am cracking my head about and decided to ask for some help, hope some of you can point me in the right direction.

Also, i think is important to mention, that there is a reason behind trying doing things like this and not trigger everything from a vbs file like it as already been suggested in this thread: Launching Rhino 5 with a batch file and running python scripts

Many thanks in advance.
Regards,
JEA

Hi @j.estevenssilva,

This batch file seems to work for me:

C:
CD "\Program Files\Rhino 6\System"
Rhino.exe /nosplash /runscript="_-RunPythonScript (C:\Users\Dale\Desktop\test.py)"

– Dale

1 Like

Hey JEA,

guess this is what you’ve been looking for:

For example, if you want to start Rhino with a file called hdri_test.3dm , render it with the built-in renderer, save the file, and exit Rhino, you would pass this:

"C:\Program Files\Rhinoceros 5 (64-bit)\System\Rhino.exe" /runscript="_SetCurrentRenderPlugIn RhinoRender render -saverenderwindowas test.jpg closerenderwindow -exit" hdri_test.3dm

from: https://developer.rhino3d.com/guides/cpp/running-rhino-from-command-line/

so in your case you just need to call the rhino.exe and add the file to open at the end. didn’t test it though

cheers

Ben

Hi Dale,
Thank you for your answer.
This is the same as my 1st Line (green) Rhino.exe is triggered and the *.rvb Scritpt runs on an *untitled file.
I am attempting to to Start an existing File and Run the script on that file.

Hi Benedict,

Thiis KB has been my starting point from the begining, however it does not seem to work in my specific case, i am guessing it has to do with the fact of having spaces in the paths:

I am modifying it like this:

“C:\Program Files\Rhino 6\System\Rhino.exe” /nosplash /runscript="-_Loadscript C:\FolderC\Folder C\ Folde C\my_script.rvb” “G:\FolderA\FolderA\FolderA\my-SpecificRhinoFile.3dm”

and ends up with this:

any clue how to go about this?
Many thanks in advance

@benedict
Update:

“C:\Program Files\Rhino 6\System\Rhino.exe” /nosplash /runscript="-_Loadscript H:\my_script.rvb” “G:\FolderA\FolderA\FolderA\my-SpecificRhinoFile.3dm

I can confirm that this sequence works(*) as long as there are no spaces in the path of the *.rvb script. Now the question is more like, how to pass spaces into the _-LoadScript argument.

By Work I mean: it opens the specific rhino file first and runs the my_script.rvb on it. (and not on an untitled file)

heya again
this seems to work for me:
"C:\Program Files\Rhino 6\System\Rhino.exe" /nosplash /runscript="_-runscript (C:\Users\Ben\Desktop\text OnSrf.rvb)" "C:\Users\Ben\Desktop\Untitled 005.3dm"

note that the scripts file name can have spaces now

hope this helps

cheers

Ben

1 Like

@benedict
Almost there I guess…, i noticed you have replaced the _-LoadScript to _-RunScript. If I do as you suggested i get this

My Batch File.txt (200 Bytes)
Any ideas ?
PS.: I know for sure the Script is working, and it always has been (no changes to the base rvb code have been made)

yeah no, its not your script. I made a mistake using runscript…sorry for that! Code: sais it all! I’d pass a path into the runscript that would ask for a code itself and not the path of the code.

it might not be very handy, but you could put in the vb code itself from the file.
update: doewn’t work either

problem is that you need a " to declare inside rhino a string, as you do in batch and they are one into another. rhino doesnt seem to have a Chr(34) function to avoid the double quotiations, so you are a bit stuck…
in fact your code needed to look like that, but its impossible:
`“C:\Program Files\Rhino 6\System\Rhino.exe” /nosplash
/runscript="_-runscript “C:\Users\Ben\Desktop\text OnSrf.rvb”"
“C:\Users\Ben\Desktop\Untitled 005.3dm”

I tried like 2 hours now various stuff and I think the most clever solution would be to create a script that has no space, which loads scripts with spaces in their names. something like call main main() rhino.command("-_loadscript"&chr(34)&<path>&chr(34)

it will be a ton easier once you’re “inside” rhino instead of passing through two interpreters that share the "

this might helps or not…I’m not so sure, haha

cheers

1 Like

@benedict,

I think you are right, we have to accept that it is not possible to use loadscript this way with the argument string having white spaces. Thank you for confirming/veryfying this, was breaking my head already for a few day.
For now i will try to make use of it by making sure the full name of my_scrpt.rvb contains no spaces this way i can make use of the this batch sequence. Will leave the development of another vbscript to bypass this procedure for another time.
Thank you all for the effort and contribution.
Regards,
JEA

noooooo!!! i was not right!

use the readcommandfile thingy! it works fine!

"C:\Program Files\Rhino 6\System\Rhino.exe" /nosplash /runscript="readcommandfile C:\Users\Ben\Desktop\txt.txt" "C:\Users\Ben\Desktop\test space\test space.3dm"

inside txt.txt:
_-loadscript "C:\Users\Ben\Desktop\test space\text OnSrf.rvb"

yaay! its maybe not a very elegant solution, but lets you just change the commands in txt

capture-20201103-155538

that avoids at least to have to rename all of your files and folders and still use the script

1 Like

:vulcan_salute: :vulcan_salute:
This should do the trick.
I actually have some identical situation with AutoCAD: a batch File loads Autocad.exe, opens a specific template file ( *.dwt), and immediately runs a generic LISP file that know where the a specific VBA code is. I knew how to solve it in AutoCAD but was clueless in how to solve with with Rhino Command line. Now i see the same principle can be used.
Thanks a lot.

1 Like