View Single Post
  #2  
Old 02-01-2014, 12:15 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Hi Anastaggra,

There is a simple solution for your problem. The problem is that with the code you provided, your variables x,y, and z are set once the code runs, and not updated when the position of the viewpoint is updated. What you need to do is to update x,y, and z after you have pressed the spacebar. So instead of running only the action, you also need to update x,y, and z. See below for an example using a sample environment that comes with Vizard:
Code:
import viz
import vizact

viz.go()
viz.add('gallery.ive')

viz.MainView.setPosition([0,1,0])
view = viz.MainView #grab the coordinate of main view
seq1 = vizact.goto([0,2,2],3,viz.SPEED, pivot = [0,2,0], ori_mask = viz.BODY_ORI)
 
#get the current position after movement of view point
x,y,z = view.getPosition()
print "Your current position is", x,y,z

def moveView():
	view.runAction(seq1)
	#get the current position after movement of view point
	x,y,z = view.getPosition()
	print "Your current position is", x,y,z

#execute action on key down
vizact.onkeydown(' ', moveView)
Good luck!
Frank
Reply With Quote