I’m looking for a pointer or an example of using command line options in a custom command. I’m sure it is out there - I just can’t seem to find it!
In the Rhino Python Editor I used “File->New>Command” and my command works great, but I’d like to add an option(s) on the command line. So when I run the command, I’d like to see something like:
Select object to analyse (Density=7850):
When I click on the “Density”, I’d like the option of entering another number.
You can add command line options to any getter - something that inherits from GetBaseClass. If you look at this class, you’ll see a number of AddOption<something> methods you can use, depending on what you’re trying to do.
For example:
import Rhino
def TestTomD():
density = 7850
density_option = Rhino.Input.Custom.OptionInteger(density, 0, 9000)
go = Rhino.Input.Custom.GetObject();
go.SetCommandPrompt("Select object to analyse")
density_index = go.AddOptionInteger("Density", density_option)
while True:
rc = go.Get()
if rc == Rhino.Input.GetResult.Option:
if go.Option().Index == density_index[0]:
density = density_option.CurrentValue
continue
elif rc != Rhino.Input.GetResult.Object:
return
break
print("Object: {0}".format(go.Object(0).ObjectId))
print("Density: {0}".format(density))
if __name__ == "__main__":
TestTomD()