|On this page|
Sometimes you want to store some data that gets passed to downstream nodes. For example, one node might parse relationships between polygons in a mesh, and create a cache that downstream nodes can access for fast lookups.
USD does not provide for temporary/unsaved data storage. USD is expected to be immutable (you can only make changes by layering new information), and all data in USD is expected to be saved.
However, Houdini needs to store temporary data (mostly about how in-memory layers should be written to disk). It stores this temporary data in the
/HoudiniLayerInfo prim. When Houdini writes out USD, it knows to skip/strip this particular prim.
This prim provides a convenient place in the stage to store your own data (as attributes) that should not be saved to disk.
The Store Parameter Values node works on a model of copying the contents of a parameter on this node (usually generated by a script) into a property on
/HoudiniLayerInfo, then, in a downstream node, generating the value of a parameter by reading the stored value. This is why the name of the node references parameter values.
This node is a workaround to allow you to store arbitrary temporary data. A future version of Houdini may have a more straightforward, dedicated way of passing temporary data down through the network.
Store temporary data using Store Parameter Values node
The node works by saving the contents of a parameter. You will usually generate the parameter’s contents using a Python script.
Set the value of a parameter downstream using stored data
A convenient way to use the stored value is to use it to set a parameter value.
If you want to encode something more complicated than a string, scalar number, or array (such as a Python dictionary), you should JSON-encode it, store it in a string, and JSON-decode it in downstream nodes to access the data.
Store Parameter script for "foo"
from json import dumps mydict = build_cache_dictionary() jsonstring = dumps(mydict) return jsonstring
Retrieve dictionary in downstream node
from json import loads import loputils this_node = how.pwd() input_node = node.inputs() jsonstring = loputils.fetchParameterValues(input_node, "foo") mydict = loads(jsonstring)
Never use Python’s
eval()function to extract data from a string. Encode and decode the data as JSON.
If you want to use the stored value in a VEX snippet:
Create a parameter for the value on the Bindings tab, or (if the node doesn’t have a Bindings tab), create a spare parameter to hold the value.
Put a Python script on the the new parameter to get its value from the stored value.
In the VEX snippet, use the bound attribute (if the node has a Bindings tab), or if you created a spare parameter, read the parameter value using a
You can’t store an array of mixed data types in a native USD array. If you use "auto" and return a list with floats and ints, it will store them as a float array. If you really need mixed types in a list, encode the list as a JSON string.
You can store multiple parameter values in a single node. Set this to the number of values you want to store, or click the plus and minus buttons to add or remove values.
For each value, whether to actually compute and store the value.
The property name to use to store the value. This should be a valid USD property name that doesn’t conflict with existing property names. You may want to add a double-underscore at the start to make it more unique. For example,
USD data type of the value you want to store. If you want to store an array, set the type to "auto" and return a string that looks like a Python list literal (for example
"[1,2,3]"). You should probably stick to
string. If you have more complex data, choose
string and encode it as JSON.
A string representation of the value to store. You will usually want to drive the value of this parameter with a Python script (see "how to" above). If you want to store an array, set the type to "auto" and make this a string that looks like a Python list literal (for example