WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-18-2009, 12:43 PM
GiudiceLab GiudiceLab is offline
Member
 
Join Date: May 2009
Location: Orono, ME
Posts: 49
Question selection of multiple properties, code help?

I am trying to modify some sound object properties on the fly, so I can hear the differences as I make changes. I know the changes will be updated without restarting the script, because I can make this work with presets.

I want to be able to select the property I want to change from a list and then use an input value to update the property.

Code:
def modifySettings(gr):
	settings = ['Environment','EnvSize','EnvDiffusion','RoomHF','RoomLF','DecayTime','DecayHFRatio','DecayLFRatio',
'Reflections','ReflectionsDelay','ReflectionsPan','Reverb','ReverbDelay','ReverbPan','EchoTime','EchoDepth',
'ModulationTime','ModulationDepth','AirAbsorptionHF','HFReference','LFReference','RoomRolloffFactor','Flags']
	select = viz.choose('Modify which setting?',settings)
	set = viz.input('Set '+settings[select]+' to')
	if settings[select] == 'Environment':
		gr.Environment = set
(twenty more elifs...)
	else:
		print 'I cannot change that setting'
Basically, I don't want to write a bunch of if statements unless I have to, so is there a simple way of doing this? Something that would be kind of like:
Code:
gr.settings[select] = set
__________________
Virtual Environments and Multimodal Interaction (VEMI) Lab

This time, it should work...
Reply With Quote
  #2  
Old 08-18-2009, 12:54 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
There are a few ways to accomplish this. If all the choice strings exactly match the attribute name on the gr object, then you can use the following code:
Code:
def modifySettings(gr):
	settings = ['Environment','EnvSize','EnvDiffusion','RoomHF','RoomLF','DecayTime','DecayHFRatio','DecayLFRatio',
'Reflections','ReflectionsDelay','ReflectionsPan','Reverb','ReverbDelay','ReverbPan','EchoTime','EchoDepth',
'ModulationTime','ModulationDepth','AirAbsorptionHF','HFReference','LFReference','RoomRolloffFactor','Flags']
	name = settings[viz.choose('Modify which setting?',settings)]
	value = viz.input('Set '+name+' to')
	setattr(gr,name,value)
Reply With Quote
  #3  
Old 08-19-2009, 03:45 PM
GiudiceLab GiudiceLab is offline
Member
 
Join Date: May 2009
Location: Orono, ME
Posts: 49
Talking

Sweet. Worked like a charm. Thanks!
__________________
Virtual Environments and Multimodal Interaction (VEMI) Lab

This time, it should work...
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
output to multiple (two) sound devices GiudiceLab Vizard 1 08-05-2009 01:12 PM
Any ideas on linking chess 3ds file with source code? djones1010 Vizard 1 04-24-2009 09:56 PM
multiple objects durf Vizard 1 04-10-2009 01:42 PM
Vizard Tip of the Month: Use Tasks to Simplify your Code Gladsomebeast Vizard 5 05-02-2008 04:30 PM
tracking with multiple LEDS dan12345 Precision Position Tracker (PPT) 7 04-02-2008 10:44 PM


All times are GMT -7. The time now is 02:23 AM.


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