PDA

View Full Version : Calling vizard functions in a loop


omidbrb
09-23-2009, 06:52 AM
Hi,

I noticed that if I call Vizard functions that have a visual effect in a loop, the commands wouldn't be run before the encapsulating function returns (even with delays in between) :


def callVizFunctionsInALoop():
for i in range(0, 10):
moveAvatar(i)
takeSnapshot()
#viz.waittime(someDelay) #Won't help
#time.sleep(someDelay) #Won't help


Here, the snapshots will be taken as if the moveAvatar() function hasn't been run.

Is there any Vizard command that will get around this problem?

Thanks
Omid

farshizzo
09-23-2009, 09:19 AM
You should be using the viztask module. There are many examples of it in the docs and on the forum.import viztask

def callVizFunctionsInALoop():
for i in range(0, 10):
moveAvatar(i)
takeSnapshot()
yield viztask.waitTime(someDelay) #Pause function for some time

viztask.schedule( callVizFunctionsInALoop() )