WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 02-10-2009, 02:00 PM
durf durf is offline
Join Date: Feb 2009
Posts: 61
Moving multiple objects with ppt


Just FYI I am new to python and Worldviz.

So far in my program I have created 3 images. A ball, a pillar, and a stage. My goal is to move the ppt sensor up, which will move the ball straight up and at the same time I want the pillar to move in the opposite direction. So in refrence... as ball moves up on the y axis positively the pillar moves down on the y axis negatively. The stage represtents the x axis which is position on y axis 0 and this represents the starting positions of my ball and pillar.

What I need to know is there any code that will make this happen? is this possible with python? and if so how can I set this code up to work?

feel free to contact me at

Sorry for no indentations. This forum is not allowing me to. Thanks for any input.

Below is the code that i have used:

import viz
import vizinfo



numLights = viz.input('How many lights are you tracking?')
numLights = min(8,numLights)

colors = [
[0, 1, 0.545],
[1, 0, 1],
[0, 1, 1],
[1, 1, 0.545],
[1, 0, 0],
[0, 0.545, 1],
[1, 0.545, 0],
[0.545, 0, 1],

sensors = []
balls = []
labels = []

for x in range(numLights):

#Create Stage
stage = viz.add('tut_ground.wrl')
stagepos = stage.get(viz.POSITION)

#Create sensor
ppt = viz.add('vizppt.dls')

#Create ball
ball = viz.add('white_ball.wrl')
ball.pptColor = colors[x]
ball.curColor = colors[x]
ballpos = ball.get(viz.POSITION)

#Create Pillar
pillar = viz.add('pillarWRL.wrl')
pillarpos = pillar.get(viz.POSITION)

def ontimer(num):
for i in range(numLights):
if sensors[i].get()[7]:

def onbutton(obj,state):
if obj == showLight:
for label in labels:
elif obj == allWhite:
for ball in balls:
if state:
ball.curColor = viz.WHITE
ball.curColor = ball.pptColor
elif obj == showBad:
if state:

def mytimer(num):
print ppt.get()

viz.callback(viz.TIMER_EVENT, mytimer)
viz.starttimer(0,0.5, viz.FOREVER)
Reply With Quote
Old 02-10-2009, 03:03 PM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,471
So it sounds like the ball just needs to be linked directly to the ppt and for the pillar you just want to negate the y coordinate. You could use the link.swapPos method for that

#create two links
ballLink =, ball)
pillarLink =, pillar)

#negate the y coordiante
in the future you can use the code tags to preserve your indentation. Select your code and click on the # icon
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lightwave objects rotation problem hosier Vizard 6 02-13-2009 12:04 PM
tracking with multiple LEDS dan12345 Precision Position Tracker (PPT) 7 04-02-2008 10:44 PM
Problems with making multiple objects from one .wrl? mjabon Vizard 3 07-10-2007 01:23 PM
Could not find plugin to load objects... halley Vizard 1 05-30-2006 11:01 AM

All times are GMT -7. The time now is 10:49 AM.

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