WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   STOP_EVENT format (https://forum.worldviz.com/showthread.php?t=949)

Jerry 12-22-2006 10:27 AM

STOP_EVENT format
 
This code works in Viz2:

def FinishedMoving(object,type):
if type == viz.MOVE:
i = 1

viz.callback(viz.STOP_EVENT,FinishedMoving)

but Viz 3 gives this error:

TypeError: FinishedMoving() takes exactly 2 arguments (1 given)

What modification is required to make it work in Viz3?

Gladsomebeast 12-22-2006 10:47 AM

Many of the events in have been changed to provide Data object as arguments which have various atributes about the event. To see what atributes an object in python has call

print dir(object)

Gladsomebeast 12-22-2006 10:50 AM

The stop event has these attributes:
action
instance
object
pool

I think you want to compare the "action" atribute to vizact.VizMove. Try printing the varioius atributes to see what you should compair to.

Jerry 12-22-2006 11:39 AM

For others who might have this question, the Viz3 way to find out if
an object has stopped moving (goto or spinto) is:

Code:


import viz

viz.go()

ground = viz.add('tut_ground.wrl')

ground.addAction(vizact.spinto(0,1,0,90,90))

def FinishedMoving(e):       

        if e.object == ground:
                print 'done'

viz.callback(viz.ACTION_END_EVENT,FinishedMoving)



All times are GMT -7. The time now is 07:05 AM.

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