WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Calling vizard functions in a loop (https://forum.worldviz.com/showthread.php?t=2278)

omidbrb 09-23-2009 06:52 AM

Calling vizard functions in a loop
 
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) :

Code:

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.
Code:

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() )



All times are GMT -7. The time now is 02:58 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC