WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   [0.0, 0.0, 0.0] for every object.getPosition() (https://forum.worldviz.com/showthread.php?t=2985)

migoloco 09-25-2010 09:03 AM

[0.0, 0.0, 0.0] for every object.getPosition()
 
I am trying to use viz.pick() to get the position for an object that a click on, but all I get is [0.0, 0.0, 0.0]. What am I doing wrong? Here is a simple example code:
import viz
viz.go()
import vizcam
viz.cam.setHandler(vizcam.KeyboardCamera())

viz.add('gallery.ive')

def showPicked():
object = viz.pick(0)
if object.valid:
print object.getPosition()

vizact.onmousedown(viz.MOUSEBUTTON_LEFT, showPicked)
Thank you very much.

farshizzo 09-27-2010 11:20 AM

Please use the [code][/code] tags when posting sample code on the forum. This will preserve indentation which is necessary for running Python code.

In your code, you are incorrectly using the valid attribute of the node object. It is a function, so you need to call it:
Code:

if object.valid():
    print object.getPosition()



All times are GMT -7. The time now is 08:43 AM.

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