GetOneObject / GetMutlipleObjects Skipping Code

Language: Python

If I run just the GetOneObject code or the GetMultipleObjects the code works just fine, but if I run both then Rhino skips GetMultipleObjects. I know sometimes the scripting engine gets stuck and produces odd results. I have reset the scripting engine and rebooted with the same results. Why would the code cause other lines to be skipped?

import Rhino

if __name__ == '__main__':
    filter = Rhino.DocObjects.ObjectType.Curve
    
    # Get one object
    sourceresult, sourceobjref = Rhino.Input.RhinoGet.GetOneObject("Select the source curve:", False, filter)
    print 'GetOneObject Result: ' + str(sourceresult)
    
    # Get multiple objects
    destresult, destobjref = Rhino.Input.RhinoGet.GetMultipleObjects("Select desitnation curves:", False, filter)
    print 'GetMultipleObjects: ' + str(destresult)

Hi @Mike24,

The easy-to-use RhinoGet.GetOneObject and RhinoGet.GetMultipleObjects are great methods when you only need to pick one set of objects. But in the cases where you need to pick more than one set, these methods don’t allow you to control pre-selection or post select, and whether or not you want pre-selected objects deselected. You’ll need to use GetObject instead.

import Rhino

def test():
    filter = Rhino.DocObjects.ObjectType.Curve
    
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select source curve", False, filter)
    if rc != Rhino.Commands.Result.Success:
        return
    print("GetOneObject.CommandResult: {0}".format(rc))
    
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt("Select destination curves")
    go.GeometryFilter = filter
    go.EnablePreSelect(False, True)
    go.DeselectAllBeforePostSelect = False
    go.GetMultiple(1, 0)
    rc = go.CommandResult()
    if rc != Rhino.Commands.Result.Success:
        return
    print("GetObject.CommandResult: {0}".format(rc))

if __name__ == '__main__':
    test()

– Dale

1 Like

@dale - Thanks Dale for your quick response!

@dale - Is there a way to get Rhino to stop repeating the SetCommandPrompt string after the first curve is selected?

Hi @Mike24,

When calling GetObject.GetMultiple? No.

– Dale