Use Rhino.Input.Custom.GetObject() more then once

How can I use Rhino.Input.Custom.GetObject() twice in a code? When I use the script below it handles only the first object.

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

objsEdge = []
objs = []

def selectObject1():
    # objs[0] First Object
    gs = Rhino.Input.Custom.GetObject()
    gs.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
    gs.Get()
    obj_ref = gs.Object(0)


def selectObject2():
    # objs[1] Second Object
    gs1 = Rhino.Input.Custom.GetObject()
    gs1.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
    gs1.Get()
    obj_ref2 = gs1.Object(0)
    
selectObject1()
selectObject1()

How about something like this:

import Rhino
import scriptcontext

def select_curves(prompt, preselect=True):
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt(prompt)
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
    go.SubObjectSelect = False
    if not preselect:
        go.EnablePreSelect(False, False);
        go.DeselectAllBeforePostSelect = False;
    go.GetMultiple(1, 0)
    if (go.CommandResult() == Rhino.Commands.Result.Success):
        return go.Objects()
    return None
    
def print_objects(objects):
    for obj in objects:
        print(obj.ObjectId)

obj_list0 = select_curves("Select first set of curves")
if obj_list0:
    obj_list1 = select_curves("Select second set of curves", False)
    if obj_list1:
        print('First set:')
        print_objects(obj_list0)
        print('Second set:')
        print_objects(obj_list1)

– Dale

It is better, Thank you. I am just wondering why the script does not work, that I tried before?

The curve that was selected during the first call to selectObject1() is still selected when selectObject1() is called the second time, and by default, pre-selected objects are used by GetObject() without allowing post-selection.

Yes that’s working. Thank you!