rvalDefferred with parameters in Maya


#1

Hi!

I’ve been tinkering with a tool and decided that would like to freeze it for a moment while it’s components load (showing a loading icon so it’s known).

For this I thought that the best was to use evalDeferred to process the loading and then give the control again to the user, and with this in mind i’ve been messing a little in another tab before adding anything to the final build.

The latest test I got is:

def printResults(metdict):
    for kv, vl in metdict.items():
        print'pre', kv, vl
        if vl:
            print'p1'
            mc.evalDeferred(kv, *vl)
        else:
            print'p2'
            mc.evalDeferred(kv)

def potatoPrint1(pot, pat):
    print pot, pat
    
def potatoPrint2():
    print 'potato2'
        
printResults({potatoPrint1 : [2, 4], potatoPrint2 : ''})

And this fails in:

Error: TypeError: file line 6: Object 2 is invalid

(I also tried with () which makes the function to evaluate before the deferred so can’t, complete list and so)

I’m unsure if it’s because it can’t be added any parameters anyway with deferred or I missed something.

The Api shows something like:
evalDeferred( [script] , [list=boolean], [lowestPriority=boolean])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis

That note throws me off about if it’s a posibility or not.

If it isn’t, is there any similar approach that can be used?


#2

Solved. Thank you.