interface version 1
Sets environment variables defined in environment scripts and loads OTLs accordingly.
Introduction
The Environment qL operator provides a simple but powerful method to set up environment variables for your scenes. It also provides a flexible way to load the assets needed by your scene.
The operator runs python scripts (called env scripts). It looks for such scripts by starting at current hip file directory, then traveling upwards in the folder hierarchy.
The whole point of the Environment qL operator is to provide an easy way to define your environment in a hierarchical and/or programmatic way. For example you can define site defaults in a site envrionment script, which can be overridden at the job level, which can be overriden again at the scene and/or at the shot level.
The operator even provides you the opportunity to override parameters on the asset interface (temporarily or permanently).
Moreover, since the env scripts are actually written in python, you can do whatever you can do with python: process file paths, run other scripts, create files or directories, or even connect to a database, etc.
Building the Environment
1. | First the operator builds a list of environment scripts by looking for files
matching the pattern specified in the Env File Pattern parameter. It starts
in your Tip You can have directory names in the Env File Pattern parameter like '.env/*.py' if you prefer to put the environment scripts in a subdirectory. |
2. | Next, the scripts are run in a top-down order (script(s) closest to the file system
hierarchy root are run first – script(s) in the If a site environment script is specified in the Site Env File parameter, it will always be the first to be run. Tip All the scripts are executed in the same local namespace, so variables and other objects (i.e. functions and classes) defined at 'higher' level scripts can be referenced and reassigned in 'lower' level ones. (Almost like if it was one single script.) |
3. | Finally, script-defined variables with ALL UPPERCASE names get exported to the Houdini environment and also listed in the Variables tab in the parameter interface. |
(The env building method is designed to be application-independent, so the same env scripts could be used from other apps with a Pyton API.)
Env Script Variables
The following variables are available in all environment scripts:
HIP | Path of the current scene file.
(Usually the same as the |
HIPNAME | The name of the Houdini scene. |
JOB | Value of the |
ENV_SCRIPT_PATH | Path of the current env script. |
ENV_SCRIPT_NAME | Name of the current env script. |
ENV_SCRIPTS | A dictionary of the scanned environment scripts in which the key is the name of the script while the value is the path to that script. While ENV_SCRIPT_PATH and ENV_SCRIPT_NAME is only available at the moment when the given script is running, this dictionary is available in the first env script that gets executed. So for example you can put the line JOB=ENV_SCRIPTS["job_env.py"] into your site environment script to indicate the you want the Warning Since keys are unique in a dictionary, and we didn’t want to overcomplicate
things, there could be only one instance of a given filename in |
The operator exports the global variables of the asset’s python module so it
provides access to the hou
module and the scene itself.
(Although this might be convenient, calling Houdini functions from env scripts break their application-independence.)
Special (Output) Variables
There are several special variables available that provide additional functionality.
MAPPINGS | You can define a dictionary called MAPPINGS = { "x:": "//server/x", "l:": "//library/l", } will translate |
ENV_VAR_ORDER | With this variable you can determine the display order of the variables coming from the scripts. For example ENV_VAR_ORDER = [ 'JOB', 'SCENE', 'SCENE_NAME', ] will cause |
OTL_PATTERN | A comma separated list of file patterns. The files mathcing the patterns will be imported as asset libraries. For example OTL_PATTERN = JOB + '/Asset/*/Otl/*.otl" will import all otl files in the 'Otl' directories in the directories in the 'Asset' directory in your JOB directory. Tip You can add new patterns to OTL_PATTERN in different scripts to import scene or shot specific assets with simple string concatenation. OTL_PATTERN = OTL_PATTERN + ':' + SCENE + '/Otl/scene_specific.otl' |
Parameters
Variables |
| ||||||||||||||||||
Time |
| ||||||||||||||||||
Settings |
|
Limitations
...
To Do
Refactoring in progress –
Finalize way(s) of message outputs (options for verbose debugging (?), etc.)
Function for substituting a regular path into a variable-based one
Describe extra funcs in help: msg(), warn(), err()
...
Release Notes
interface version 1 —
2014-10-04 |
|
2014-09-29 | Internal refactoring and cosmetics –
|
2012-12-05 | Matured the scheme based on user feedback. |
2012-11-01 | Initial release. |