I have the below python code in which I implement a function _options
that can prompt command line options. I need to call the function twice to get different objects. However, it only prompts once, and for the second time, it directly get the result from the first one without prompting anything for input.
Can anyone help me out with this? Thanks!
import rhinoscriptsyntax as rs
import Rhino
def _xx():
def _options(msg, dft):
"""
Use command line options as input
args:
msg: String.
dft: Int. 1 or 0.
Return:
List of GUIDs
"""
# Init base getter
gi = Rhino.Input.Custom.GetObject()
gi.SetCommandPrompt(msg)
gi.GroupSelect = True
gi.AlreadySelectedObjectSelect = False
# set up the options
boolOption = Rhino.Input.Custom.OptionToggle(bool(dft), "False", "True")
gi.AddOptionToggle("Meshed", boolOption) # Hyphen not allowed
# set filter based on options
if boolOption.CurrentValue:
gi.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh
else:
gi.GeometryFilter = Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.Brep
while True:
get_rc = gi.GetMultiple(1,0)
if gi.CommandResult()!=Rhino.Commands.Result.Success:
# return None if nothing selected
return
elif get_rc == Rhino.Input.GetResult.Option:
# set filter based on options
if boolOption.CurrentValue:
gi.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh
else:
gi.GeometryFilter = Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.Brep
continue
break
ids = [gi.Object(i).ObjectId for i in range(gi.ObjectCount)]
newdft = int(boolOption.CurrentValue)
return ids, newdft
# read default option values
a = 0
b = 0
# Get ids
result1 = _options("select A surfaces", a)
result2 = _options("select B surfaces", b)
print result1
print result2
return
if __name__ == "__main__":
_xx()