Command line option not updating

Ok so I changed the script from this link: Add command line options such that the Getpoint keeps repeating until I Esc out of it. I also removed all options except for the integer option. And I added “intOption.CurrentValue+=1” to make the integer increase by 1 each time you make a point.

But the problem is that it’s not showing the increased integer in the command line until I click on that option. Then it show’s me the current integer.

So it keeps showing me this after each point I place
until I click on the option and then it shows me the updated Integer after placing a few points (4 in this case)

Can anybody help me out here? How do I update the commandline option after placing each point to match that new integer? And perhaps a better question: How do I search and find things like this without having to ask somebody else that knows this?

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)
    gp.AddOptionInteger("Integer", intOption)
    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()
        elif get_rc==Rhino.Input.GetResult.Option:
            if gp.OptionIndex()==opList:
                listIndex = gp.Option().CurrentListOptionIndex
        if get_rc == Rhino.Input.GetResult.Cancel:
    return Rhino.Commands.Result.Success

if __name__ == "__main__":

Hi @siemen, see if this script helps, i’ve added some comments: (1.7 KB)

It’s hard to find and has only been asked once. But asking again does not hurt.


1 Like

Thanks again @clement!

2 more questions:
Why did you add that “.EnglishName” to the option name?
And why do you need this: scriptcontext.doc.Views.Redraw()? I don’t see the difference with or without this.

So where do you find it and how do you search? I sometimes manage to find some info on the developers website but often don’t manage implementing those things.

Hi @siemen, in case you add more than one commandline option, you need to have a way to distinguish them from each other. All code below the line

elif get_rc == Rhino.Input.GetResult.Option:

is called whenever the user picked one of the available command line options. The


was already in the script example above. It may be not required here since the point getter redraws constantly.


I’m still not 100% sure I get it. So you distinguished this option by naming it “EnglishName”? Or? So should you give every option a name if you have multiple options?

Hi @Simen, no i did not name it, EnglishName is a property of a CommandLineOption which you can use to get the name which you assigned when adding it. Say you add two different options to your point getter like this:

# add a first command line option to enter an integer between 1 and 99
optInteger = Rhino.Input.Custom.OptionInteger(1, 1, 99)
gp.AddOptionInteger("MyInteger", optInteger)
# add another command line option to toggle something
optToggle = Rhino.Input.Custom.OptionToggle(True, "No", "Yes")
gp.AddOptionToggle("MyToggle", optToggle)

then the user picks one of the two available CommandLineOptions, you’ll want to find out which one and perform some action. This happens like below:

elif get_rc == Rhino.Input.GetResult.Option:
    # user picked an option, find out which by getting the option name 
    if gp.Option().EnglishName == "MyInteger":
        print "MyInteger = {}".format(optInteger.CurrentValue)
    elif gp.Option().EnglishName == "MyToggle":
        print "MyToggle = {}".format(str(optToggle.CurrentValue))

The reason why i wrote it like this in my above example:

option_name = gp.Option().EnglishName

was just that i then have less typing in case of many options. Does this help ?


1 Like

Got it. Thanks for the explanation again @clement!