Hyphenated commands


How can I query from the C++ command code if the command was prefixed with a hyphen?

I would like to have two versions of a command:

  • one without options (which uses the currently active option settings)
  • a hyphenated one with options (to change the option settings)

similar to the Fullscreen command, for example:

Fullscreen + [Enter] => change to fullscreen mode using the currently active option settings

-Fullscreen + [Enter] => Set fullscreen options (ShowLayer=No ShowCommand=Yes…): [Enter] => change to fullscreen mode using the new edited option settings

Thanks for your help,

Try this:

CRhinoCommand::result CCommandTest::RunCommand( const CRhinoCommandContext& context )
  if( context.IsInteractive() )
    // Show dialogs
    // Don't show dialogs
  return CRhinoCommand::success;

We typically write our commands so that when no hyphen is present, it is ok to show user interface like a dialog and when a hyphen is present, show command line options. It isn’t a rule, but it is how all of the other commands in Rhino act.

Hi Dale,

Thank you! That is exactly what I was looking for : )


Hi Steve,

Thank you as well!

I wanted to do exactly the opposite…

I am working on a common lisp interpreter for Rhino. I called it “RhinoLisp”.

My Idea was as follows:

  • When started the first time, “RhinoLisp” asks for a file to interpret. The file path is stored and following calls of the command use the same file. This is nice as the file can be edited and then reevaluated just by hitting the space key…

When the user wants to change the file, he uses the “-RhinoLisp” and a file dialog is opened to select a new file.

Unfortunately this seems not to be in accordance with your usage of hyphenated commands then…

Any better ideas how to achieve a similar effect?

Maybe two different commands are better?

Something like

  • RhinoLisp and
  • RhinoLispOpen

Using “RhinoLisp” as common prefix, or

  • RunLispScript (…which would be inline with RunScript and RunPythonScript) and
  • OpenAndRunLispScript (…which is a little too verbose for my taste)

Any better ideas?

Thanks, Dietrich

When you run “-RhinoLisp”, you should prompt the user for a filename string using a CRhinoGetString object. As part of prompting for a string, you might want to add a “Browse” command line option. By picking Browse, you could then display a file dialog.

For an example of this, launch Rhino and run “-Save”. Notice the “Browse” option…

I would create a “RunLispScript” and use CRhinoGetString to get input in the dashed version as @dale suggests. The string that is returned could either be a path or the entire script. This would allow the script to be embedded in a toolbar button. The non-dashed version could show a file dialog box.

I would also create a “RunPreviousLispScript” to do what you were thinking of for repeating the previous script.

This is just my initial guess; I’m sure users may have alternate opinions once they have something to play with. Looking forward to seeing your work.

Hi Dale, hi Steve,

Thank you very much for your suggestions!

Steve> I’m sure users may have alternate opinions once they have something to play with.

I like both approaches. So for the time being I will implement them both and leave the decision to the user.

Thank you also for the idea to allow entire scripts at the place of a file path!

Steve> Looking forward to seeing your work.

Thank you : ) I will clean it up a bit and then post a very simple first version for the case that somebody is interested.

I am using Embeddable Common Lisp (ECL, http://en.wikipedia.org/wiki/Embeddable_Common_Lisp , http://ecls.sourceforge.net/ ) to implement the common lisp interface.

ECL makes it easy to extend the functionality in common lisp or C++, whatever is faster or handier. Unfortunately the common lisp wrappers have to be coded mostly by hand. This could be seen as a feature as well, as ECL’s mixed programming style encourages a flexible approach to scripting and the creation of domain-specific languages. Also it is possible to optimize scripts by implementing critical parts in C++. But it also adds an extra level of complexity and it would be nice to be able to automatically generate default wrappers as well : )

By the way, how is the .NET bridge to C++ implemented? By hand? Do you generate it automatically?

Thanks, Dietrich

I have the same question, but using Rhinoscript? Is it possible?

Hi Jonah,

There is lot to this thread - what specifically is your question?

Hi Dale. Using Rhinoscript - Is it possible to detect if user called the hyphenated or the non-hyphenated version of a command?


There is no method in RhinoScript that will tell you whether or not the last executed command, called with the RunScript method, was executed in scripted (hyphenated) or interactive (non-hyphenated) mode. It is be possible to add something that would report this. Why would you need this?

I would like to allow users to access options, but not have to always go through the extra step in command line each time they run the command. Sort of like the behavior of Rhino’s Fullscreen command and its hyphenated version…

Sorry for being dense, but I don’t understand what you are asking for, in RhinoScript. Can you try to explain what problem you are trying to solve and how you think RhinoScript can help solve it?

As with Fullscreen, running the non-hyphenated command simply performs the action of going fullscreen. But when using the hyphenated -Fullscreen, you will get a set of options before going fullscreen… The goal is to avoid going through a step of options if someone wants to use it in a pre-determined manner…

Sorry, I still don’t see how RhinoScript is going to help with this.

Hi Dale,

I couldn’t find any way to add options to CRhinoGetString.
CRhinoGetOption on the other hand doesn’t seem to allow the input of strings…

How is the Save command implemented? Or better: How can I add a “Browse” option when propting for a file name with CRhinoGetString?

Thanks, Dietrich

See if this example helps.


Hi Dale,

This example absolutely helps!

And you solved the next problem (the implementation of a lisp file browser) as well without even asking for it!

Thanks a lot for such a nice example of proactivity : )


PS: Looking at this perfect support, maybe I just should have asked “do you have any idea how to script Rhino in common lisp?” and wait for you to solve the problem altogether : )

I just wonder why I wasn’t able to solve this myself: I definitely tried

CRhinoGetString gs;
gs.AddCommandOption( RHCMDOPTNAME(L"Browse") );

myself - but for some reason had the impression that AddCommandOption() was just not defined for CRhinoGetString. Anyway, I am happy that you proved me wrong : )