Multiple parameters and options in one command line with Python

Is there a way in Rhino python to address multiple dimensions or options in one single the Rhino command line?
Like in a normal Rhino command where you for example have to define the extrusion distance in the command line and then in parenthesis have the possibility to change the direction, delete input etc.
This would be very useful so that you don’t have to hit enter 5 times to confirm parameters that you usually don’t want to change.
I’m not sure if I’m clear. I’m new to Rhino python and not sure about the whole terminology. So it might be possible that I oversaw a thread or an example that explains my question.
In my example I would like to select one or multiple curves and then have a toggle option and some dimension values.

Yes, it certainly is possible, but not with rhinoscriptsyntax, for that you would have to dive into some RhinoCommon. If that interests you, here is a page with sample code.

That being said, I found that it is often just as easy to ask the user for a series of choices sequentially rather than all on one command line, there are just as many mouse clicks involved… The advantage of having the command line options is you can change your mind on any of them until you validate with Enter…

HTH, --MItch

forum member @emilio gave me an example of doing this once which i was able to use in a script… the post where he provided some examples is here:

further in the thread is a script i made using emilio’s share.

Thank you Mitch and Jeff!

But guess I rather stick to rhinoscriptsintax for the moment.
I don’t feel comfortable to dive into RhinoCommon just yet;)

Hi Mitch

I also find command options useful when the script could use default values (possibly using latest used values as defaults)
You just set those options to their default values in the script and if they are what the user wants there is no need for extra clicks.

Hehe … OK … I’m often quite lazy. :slight_smile:


1 Like

hello, i try to make a multiple option in a command line, but it don’t run,
the option aren’t in the command line, have you an idea?

#coding: utf-8
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext

def getOptions( eppnx,lgmort,decalmort,espmax ):
    while True:
        gnu = Rhino.Input.Custom.GetString()
        gnu.SetCommandPrompt( 'Option de mortaise' )
        gnu.SetDefaultString( 'Ok?' )
        gnu.AddOptionInteger("Epaisseur Panneaux", Rhino.Input.Custom.OptionInteger(eppnx, 5, 50))
        gnu.AddOptionInteger("Longueur de la mortaise", Rhino.Input.Custom.OptionInteger(lgmort,80,300))
        gnu.AddOptionInteger("Decalage de la mortaise/Ext", Rhino.Input.Custom.OptionInteger(decalmort,80,300))
        gnu.AddOptionInteger("Espace Max entre mortaise",Rhino.Input.Custom.OptionInteger(espmax,600,1300))
        if gnu.CommandResult() == Rhino.Commands.Result.Cancel:
        res = gnu.Result()
        if res == Rhino.Input.GetResult.Option:
            opind = gnu.OptionIndex()
        elif res == Rhino.Input.GetResult.String:
            number = gnu.Number()
    result = 1
    return result

s=getOptions( 16,100,150,600 )
print s

Except for the prompt, the various strings in the options cannot have spaces…

I.e. instead of ‘Epaisseur Panneaux’, use ‘EpaisseurPanneaux’