Questions about --Sample: Add Command Line Options

from here:

import Rhino
import scriptcontext
def CommandLineOptions():
    # For this example we will use a GetPoint class, but all of the custom
    # "Get" classes support command line options.
    gp = Rhino.Input.Custom.GetPoint()
    gp.SetCommandPrompt("GetPoint with options")
    # set up the options
    intOption = Rhino.Input.Custom.OptionInteger(1, 1, 99)
    dblOption = Rhino.Input.Custom.OptionDouble(2.2, 0, 99.9)
    boolOption = Rhino.Input.Custom.OptionToggle(True, "Off", "On")
    listValues = "Item0", "Item1", "Item2", "Item3", "Item4"
    gp.AddOptionInteger("Integer", intOption)
    gp.AddOptionDouble("Double", dblOption)
    gp.AddOptionToggle("Boolean", boolOption)
    listIndex = 3
    opList = gp.AddOptionList("List", listValues, listIndex)
    while True:
        # perform the get operation. This will prompt the user to
        # input a point, but also allow for command line options
        # defined above
        get_rc = gp.Get()
        if gp.CommandResult()!=Rhino.Commands.Result.Success:
            return gp.CommandResult()
        if get_rc==Rhino.Input.GetResult.Point:
            point = gp.Point()
            print "Command line option values are"
            print " Integer =", intOption.CurrentValue
            print " Double =", dblOption.CurrentValue
            print " Boolean =", boolOption.CurrentValue
            print " List =", listValues[listIndex]
        elif get_rc==Rhino.Input.GetResult.Option:
            if gp.OptionIndex()==opList:
              listIndex = gp.Option().CurrentListOptionIndex
    return Rhino.Commands.Result.Success
if __name__ == "__main__":

i have a script which starts off with the user having four input choices… two are booleans and two are real numbers… (then a fifth depending on one of the boolean choices)…

so it starts off with 3-4 boxes popping up but the sample script above seems like i could consolidate it all into one popup (mac)

my first question is what do i have to use to just get the options but not GetPoint along with it?

(so far, i only know about the rhinoscriptsyntax stuff)

my other question is if there’s a way to write this with import_rhinoscriptsyntax stuff instead of import_Rhino ?

it gets sort of confusing when i see all sorts of different python examples using varying modules to accomplish in many cases what at least seems like is accomplishable with rhinoscriptsyntax…

or- there’s nothing i’ve come across so far which says ‘hey- you need to learn about rs.GetPoint but you also need to learn about Rhino.Input.Custom.GetPoint’… like- there are some things you can Get via this module which aren’t available in that one and viceversa…

anyway, just confused as always so any insight on the second bit is welcome… but more important for my immediate concerns would be how to use the sample script without getting a point

You’re right Jeff.
RhinoCommon allows for far more things than rhinoscriptsyntax.
( rhinoscriptsyntaxis is its self written in RhinoCommon )

I know no way to handle input options in rhinoscriptsyntax, I always have to use RhinoCommon for that.
And … yes, RhinoCommon input options are more complex to use compared to rhinoscriptsyntax (for me)
and there’s also more lines of code to write, but they offer you a lot of possibilities …

If you don’t need to get a point, you can use GetOption.
In the RhinoCommon reference docs you can find several different (similar) classes that let you input several kinds of data.

Hey Jeff,

As Emilio said, RhinoCommon is quite a bit more powerful than rhinoscriptsyntax, but with that power comes complexity. GetOption is particularly complex, because it has, well, a lot of options… :smile:

A simple rhinoscriptsyntax workaround for just choosing from a list of options would be to use rs.ListBox() with your options. Unfortunately, this method in not yet implemented in Mac rhinoscriptsyntax (at least last i checked).

Another workaround would be to use rs.GetString(), which does work on Mac, and allows you to use a list of strings as options. On Mac that gives you a small dialog with a checkbox IIRC.


thanks @emilio / @Helvetosaur

wow… after looking through the rhinoCommon references, i’m not sure i’m willing to make that type of commitment… or, i don’t know if i have any practical use to learn scripting to that degree.

in actuality, i’d really rather just spend time learning grasshopper but since i can’t for the time being, python/rhinoscriptsyntax seems to be filling this yen for me. :smile:

(plus, i think it will be good to have a basic grasp on scripting and/or python when the time comes that grasshopper is available for osx)

i think i’ll just continue learning about python on my current track then maybe pick up some of the rhinocommon stuff on an as needed basis… such as making a better UI for the script i’ve been working on.

i think i’ll be able to get it to work right with what i can see in the example and the getOption documentation but if not, i’ll be back with another question i’m sure.

thanks again for you time.


Could we get a python sample on this page?

Note that this is the page linked to from

Note, there is another, similar page here:

This one does not appear to have a link from

Thanks, --Mitch

Hi Mitch,
I added this to my task list.