using: rhino python
hello, I am trying to have a user select a series of mesh edges, and after each selection run a function which uses the selected mesh edge index. The idea is to let the user select either single edges or chains of edges associated with a single edge. Thus the code should ask the user to select an edge, with the options of making it a chain or leaving it alone.
I found this example for getting a point with command line options in the rhinocommon docs. With the ‘break’ statement removed (as I did below) one can set any number of points, with options:
import Rhino import scriptcontext def CommandLineOptions(): gp = Rhino.Input.Custom.GetPoint() #if this is changed to GetObject() rhino gets stuck. 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(False, "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) gp.Get() while True: get_rc = gp.Get() if gp.CommandResult()!=Rhino.Commands.Result.Success: return gp.CommandResult() if get_rc==Rhino.Input.GetResult.Point: point = gp.Point() scriptcontext.doc.Objects.AddPoint(point) scriptcontext.doc.Views.Redraw() 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 continue #break #I removed this so that one can pick any number of points return Rhino.Commands.Result.Success if __name__ == "__main__": CommandLineOptions()
this is basically exactly what I want to be able to do, but for meshEdges. I would have the loop break if a user presses ‘enter’ or ‘esc.’ Unfortunately, if I change the above code to use Rhino.Input.Custom.GetObject() in place of Rhino.Input.Custom.GetPoint(), rhino stops responding. I have tried playing around with Dispose() but that does not seem to help.
Alternatively, is it possible to use GetMultiple(), but tag each selection with input from the command line options? Or is there a better way of doing this? why is this happening?
thanks in advance!