Exit rhino from script/command file


#1

Hi!

I have a script in Rhinoscript for automating/batching some computations in rhino remotely.

I use in my script Rhino.DocumentModified “False” to avoid the prompt asking to save modified file so if I write manually _Exit in the command line after executing my script, Rhino close itself without asking so is perfect.

But if I use in my script Rhino.Exit or Rhino.Command("_Exit"), this doesn’t work. Rhino is still opened.

I got Rhino closed if I play my script from Rhino Script Editor in Rhino but I need to call my script remotely, so I have to compile it as a plugin to be able to execute it outside the Editor, as a command in the Rhino Command Line.

Really I need to call Rhino from Windows command line, like this:

“C:\Program Files\Rhinoceros 5.0\System\Rhino.exe” /runscript="_myscriptname"

Rhino starts and executes my script but does’t close.

Even if I I call it from Rhino command line manually it doesn’t work (executes evertything in the script but doesn’t close Rhino).

Is there a way to close rhino from script plugin? May It is not possible…

Any help would be really appreciated!

Thanks in advance.

Regards,

Enrique de Meer


RhinoScript – Rhino.Exit doesn't work in an IF statement
#2

Hi,

I am trying to explain better my problem.

For example, this script file:

Option Explicit

Sub Salir()

        Rhino.Exit
        
End Sub

Call Salir

If I do in the Rhino Command Line: > -_LoadScript myScriptAbove
then Rhino Closes.

But if I compile my script with Monkey and write the command name in my Rhino Command Line then Rhino does nothing.

Any help, please?


(Dale Fugier) #3

What do you mean by “call the script remotely?”


#4

Hi,

I mean using this: http://wiki.mcneel.com/developer/commandline

If I use the text below in a .bat file:

“C:\Program Files\Rhinoceros 5.0\System\Rhino.exe” /nosplash /runscript="-_LoadScript C:\myscript.rvb"

Rhino opens, executes the script and closes. OK

But if I compile with Monkey myscript.rvb to get mysript.rhp and I install it in Rhino as a plugin, then if I execute this with my .bat file:

“C:\Program Files\Rhinoceros 5.0\System\Rhino.exe” /nosplash /runscript=“myscriptcommand”

Rhino opens, executes the script but does not close. It is like command Rhino.Exit in my script does not work.

And furthermore, if I open Rhino manually and write in Rhino command line “myscriptcommand”, it does nothing.

I hope you understand better my scenario.

Thanks in advance,

Enrique.


#5

“C:\Program Files\Rhinoceros 5.0\System\Rhino.exe” /nosplash /runscript=“myscriptcommand _exit”

or at least this worked :smile:
“C:\Program Files\Rhinoceros 5.0\System\Rhino.exe” /nosplash /runscript="!line 0,0,0 0,10,0 -_exit"

This should work… Just tested it :slight_smile:

And did you drag the rhp in rhino before you tested it?


#6

Hi,

"C:\Program Files\Rhinoceros 5.0\System\Rhino.exe" /nosplash /runscript="myscriptcommand _exit" does not work because my script has several “Rhino.command(any)” sentences inside and if I do what you suggest then _exit is written in the rhino command line not at the end but in the middle and it does not work.

And if I write Rhino.command("_Exit") at the end of my script instead of Rhino.Exit then _Exit is written in Rhino command line by my script but it does nothing.

But what do you mean with “drag the rhp in rhino”? I install it as a plugin in Options menu. This way I have a command word to write in the command line, and everything in my script is executed but not Rhino.Exit or Rhino.command("_Exit").

Thanks,

Enrique.


#7

I understand what you mean on the first part. If I create a plugin with only rhinoapp.exit and I run the command rhino closes. No idea why it wouldn’t work.

With drag and drop Its the same as installing it via the options menu.


#8

try this:

/nosplash /runscript="!line pause pause -_exit"

if you use rhino.command use Pause where the user has to give information. Then it will work


#9

Thank you very much for your help but I am stucked in the same.

If I drag and drop the .rhp file I have the same result than installing it in Options menu.

And if I use pause it does not work because I have several commands and rhino throws “pause” or “exit” as a command just after the first Rhino.command() of my script, not at the end of the execution of the entire script.

Because if I run /runscript=" -_exit" then it is perfect. Rhino opens and closes. The problem is when I try /runscript="myscriptcommand -_exit", becuse -_Exit is not written after the whole execution of all the sentences in my script. It is wriiten in rhino command line just after the first Rhino.command() of my script, having no effect, If it would close Rhino it will not be OK but I woud understand it!

When you say If I create a plugin with only rhinoapp.exit and I run the command rhino closes, you mean it works for you???


#10

Yeah when I create a vb.net plugin. And indeed dragging and installing it with options has the same result.

I mean that you have to use pause in your script.

You said you use rhino.command() in your scripts? thats where I meant you have to throw the pauses :wink:

You can try to make a small command like you are making now. But then try to do rhino.command(line pause pause) then in you batch use _exit after the command.


#11

I’ve trying with Pause in many places and nothing.

I don’t think this is good for me, because I am not expecting any user inputs. Actually I want to execute my script through my batch file so I don’t want any user interaction.

Thank you but I think the real problem is why Rhino.Exit does not work inside a plugin, or why it is not working for me.

At least I have the workaround with /runscript="-_LoadScript C:\myscript.rvb", where Rhino.Exit does close Rhino after execution, but I thought It is not much correct.

Thank you anyway


#12

Enrique de Meer,

I am currently having the same issue. Did you find a solution?

Thanks,

Ariel


#13

For anyone else having this issue try:

import rhinoscriptsyntax as rs
rs.Exit()


#14

What is this? Python?

I am using Rhinoscript…


#15

Rhino.Exit()


#16

yes, Rhino.Exit sometimes works, sometimes doesn’t.

I have found out several Rhino commands that work like this…


#17

I’ve experienced the same issue when using a startup script for a command-under-construction in a BAT-file. The command-under-construction causes changes to the document and I found that the command “Exit” does not support RunMode Scripted. If running scripted it still shows a Yes-No-Cancel dialog instead of command line options.

I don’t know whether this is by design nor whether this is the cause of not being able to close Rhino from the /runscript argument.


#18

Running DocumentModified before exiting shoulld prevent the Yes/No dialog from coming up. In RhinoScript (vb) this would be:

Rhino.DocumentModified(False)

or in python scripting:

import rhinoscriptsyntax as rs
rs.DocumentModified(False) 

c.


(Dale Fugier) #19

HI Gerco,

Because of this issue, the issues mentioned above, and other limitations with command line scripting, such as a character limit, we recommend automating Rhino, using Visual Basic Script (vbs) for example, instead of running Rhino from the command line with the /runscript option. By automating Rhino with vbs, you can do everything can do using batch scripting, plus you can query Rhino and make decisions.

Here are a couple of examples of automating Rhino using vbs. The first example just launches Rhino, adds some geometry, and saves the file. The second example will render a 3dm file.

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinoscript/TestRhino5Automation.vbs
https://github.com/mcneel/rhino-developer-samples/blob/6/rhinoscript/TestRhino6Automation.vbs
https://github.com/mcneel/rhino-developer-samples/blob/6/rhinoscript/RhinoRender.vbs

– Dale


#20

Hi Dale,

Could you share those link again? I am getting a 404 error on the links that you have provided here.