HscriptCookbook
From Odwiki
HScript CookBook
Here is a list of some common operations done in HScript which you might find useful.
Traversing nodes
- Recursive script to loop through all nodes in a given tree:
# this is a file called recurse.cmd
#
if( `ishvariable("RECURSING")` == 0 )
# this section of code is called the first time this script is executed
#
set saved_path = `execute("oppwf")`
echo "starting recursion at $arg1
cd $arg1
set -g RECURSING = 1
source recurse.cmd
set -u RECURSING
opcf $saved_path
else
# this section of code gets called for every node
#
set nodes = `execute("opls -a")`
foreach node ($nodes)
if( `opnchildren("$node")` > 0 )
echo "diving down into network: $node"
cd $node
source recurse.cmd
cd ..
else
# here is where you process the node
#
echo --processing $node
#
endif
end
endif
- Very simple script to loop through all nodes in a given tree using opfind:
set allnodes = (`execute("opfind -p $arg1")`)
foreach node ($allnodes)
echo process the node $node here
end
Manipulating OTLs
- Find out which OTL a certain operator in a scene is from: ($arg is the requested node, output in $otl)
set optype = `execute("optype -o $arg1")`
set otl = `execute("otgetotl $optype")`



