20.08.2015 Views

1 Scripting

1 Scripting - Digital Cinema Arts

1 Scripting - Digital Cinema Arts

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The <strong>Scripting</strong> Language2.7 USING ARGUMENTS IN SCRIPTSThe source command, when entered at the c-shell prompt, can have arguments afterthe .cmd Þle name. These arguments are set to Houdini variables so that they can beused by the script. For example:houdini-> source repeat.cmd 1 10 2 blockheadwhere repeat.cmd contains the Houdini script,echo Hello, my name is $arg4for i = $arg1 to $arg2 step $arg3echo I said, my name is $arg4endNote that there are four variables in the script: arg1, arg2, arg3 and arg4. These areset to the source arguments 1, 10, 2 and blockhead respectively. This mechanismworks well with the -g options of the rcwrite and opdump commands, which causeobject names to be written out generically, as $arg1, $arg2 and so on. In this way,names of objects can be changed when reading them as scripts.$ARG0 – NAME OF THE SCRIPTYou can get the name of the script being run from $arg0. For example:source myscript.cmd 1 4.5 7 balloonwill come into the script with$argc = 5$arg0 = myscript.cmd$arg1 = 1$arg2 = 4.5$arg3 = 7$arg4 = balloonThis allows usages such as:if $argc != 5 thenecho USAGE: source $arg0 numclowns clownsize numtoys toytypeexitendif$ARGC – NUMBER OF ARGUMENTS PASSED TO SCRIPTThe number of arguments passed to the script can be retrieved with the variable$argc, for example, from the lookat.cmd script:# USAGE: lookat.cmd eyeobject focusobjectif $argc!= 2 thenecho USAGE: source lookat.cmd eyeobject focusobjectexitendif86 1 Houdini 6.0 Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!