Dynamic dropdown menu listing mantra nodes with a menu script.
Pulldown menus in HoudinI!
Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Friday August 01st, 2008 02:54 AM
CREATE: Dynamic dropdown menu listing mantra nodes with a menu script.
* This dropdown menu will allow us to control any mantra nodes dynamically.
* Create a string parameter, change the name to "node", Label to "Select Node:"
* Go to the Menu tab in Type Properties.
* Toggle on Use Menu, as well as Menu Script.
* Menus require two values, Token and Label.
* Token is the value you would get when using chs().
* Label is what you see when you are navigating through the menu items.
# Basic menu script to understand using two values:
# One value for Token, and the second value for Label:
echo 1 on
echo 0 off
# Menu script using foreach():
foreach x(`("object light shadow")`)
echo $x $x
end
* Use expressions like strreplace() on the label to make menus look nicer
* Use the run() expression to return the output of Hscript commands.
* Use the following code in the menu script:
# Lists all nodes of type "mantra", within the path "/out"
foreach x(`run("opfind -p /out -t mantra")`)
echo $x `strreplace($x,"/out/","")`
end
* Create a string parameter, change the name to "parameter", Label to "Select Parameter:"
* Go to the Menu tab in Type Properties.
* Toggle on Use Menu, as well as Menu Script.
* Use the following code:
# Lists all the parameters of the selected node:
set OP = `chs("node")`
foreach z(`run("opparm -l $OP *")`)
echo $z $z
end
* Create a string parameter, change the name to "value", check off Label.
# This is used as a callback on the parameter string to "get" the values:
opparm `oppwf()` value ("`chsraw(chs("node") + "/" + chs("parameter"))`")
# This is used as callback on the value string to "give" the values.
opparm `chs("node")` `chs("parameter")` ("`chsraw("value")`")
* The difference between `chs()` and `chsraw()`:
echo `chs("mantra1/picture")`
/home/prisms/test.jpg
echo `chsraw("mantra1/picture")`
$HOME/test.jpg
* Use source command along with chs() to source a script depending on what you select from pulldown.
source opdef:.?`chs("button")`
