Python: Simple Command Line Option


#1

Hi and a Happy New Year to the Rhino Community!

I’m playing with the CommandLineOptions.py which demonstrates options like toggles, lists, double and integer types. But how can I add a simple option like for example “Undo”?

I think I can modify the script to really undo the last point input, I really just wonder how to implement such a simple command option.

Thanks and best regards,
Jess


(Menno Deij - van Rijswijk) #2

Use AddOption like so:

opUndo = gp.AddOption("Undo")

Then, later in the while loop

elif get_rc==Rhino.Input.GetResult.Option:
            if gp.OptionIndex()==opList:
              listIndex = gp.Option().CurrentListOptionIndex
            if gp.OptionIndex()==opUndo:
               #undo logic comes here
            continue

#3

Thanks Menno! Tricky and easy…