PDA

View Full Version : STOP_EVENT format


Jerry
12-22-2006, 10:27 AM
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:



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)