WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-30-2011, 07:48 AM
sleiN13 sleiN13 is offline
Member
 
Join Date: Dec 2008
Posts: 83
getVisible unexpected behaviour

I wanted to use the visibility of a object to execute (or not) certain code in a vizAction to my surprise all object returned getVisible() is True while I knew that the certain parent object where invisible. A simple test confirmed that child object don't return the correct visibility value

Code:
groupA = viz.addGroup()
groupB = viz.addGroup(parent = groupA)

groupA.visible(viz.OFF)
print groupB.getVisible()

>>> True
Is this a bug or by design and in case of the second reason is there a function that will give the result I need?
Reply With Quote
  #2  
Old 12-13-2011, 12:17 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
This is by design. The node.getVisible() command returns the visible flag of the node. It does not take into account the visible flag of any parents.

You can use the node.getParents() command to determine the visibility state taking into account all parent nodes. Example:
Code:
import viz
import vizact
viz.go()

group1 = viz.addGroup()
group2 = viz.addGroup(parent=group1)
ball = viz.addChild('beachball.osgb',parent=group2,pos=(0,1.8,2))

label = viz.addText('',parent=viz.ORTHO,fontSize=50,pos=(10,10,0))

def isNodeActuallyVisible(node):
	if not node.getVisible():
		return False
	parents = node.getParents()
	if parents:
		return any(isNodeActuallyVisible(p) for p in parents)
	return True

def UpdateLabel():
	if isNodeActuallyVisible(ball):
		label.message('visible')
	else:
		label.message('not visible')
vizact.ontimer(0,UpdateLabel)

vizact.onkeydown('1',group1.visible,viz.TOGGLE)
vizact.onkeydown('2',group2.visible,viz.TOGGLE)
vizact.onkeydown('3',ball.visible,viz.TOGGLE)
Reply With Quote
Reply

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
Strange Ball Joint behaviour mkmatlock Vizard 1 11-04-2010 04:49 PM
Unexpected carriage return vizmaster Vizard 3 01-23-2007 12:46 PM
Tk with Vizard abnormal behaviour Gilliard Vizard 2 08-04-2005 01:14 AM


All times are GMT -7. The time now is 05:41 PM.


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