import maya.cmds as mc forestsGlobalItem = None def User_Select(): global forestsGlobalItem print "USER" ctx=mc.scriptCtx( title='Select Something', totalSelectionSets=1,\ fcs="select -r $Selection1; python(\"Sel_Func('\"+$Selection1[0]+\"')\");",\ cumulativeLists=False, expandSelectionList=True, setNoSelectionPrompt='Select Object',\ setSelectionPrompt='Never used', setDoneSelectionPrompt='Never used because setAutoComplete is set',\ setAutoToggleSelection=True, setSelectionCount=1, setAutoComplete=True) mc.setToolTo(ctx) forestsGlobalItem = None while forestsGlobalItem is None: pass item = forestsGlobalItem forestsGlobalItem = None return item def Sel_Func(item): global forestsGlobalItem print "PRINT My Function", item forestsGlobalItem = item