Going through and manually swapping $HIP
for $JOB
, or switching any value
for another one in an entire hipfile can be a real pain. You could try doing the
long way (looking at each parm and changing by hand….ouch!), or by iterating
all the parms on all the nodes with Python. Or, you can use a simple built-in
HScript command: opchange
.
opchange
makes
it really simple to swap values across the entire scene, or in a limited scope
of nodes.
Example
Let’s say you were loading a bunch of HDRIs from some sort of library you have
elsewhere on disk, but now you need to share the project with someone else.
You’ve copied all the light textures from your library location into $JOB/tex
,
but now you need to change all the paths on the lights in your hipfile. We can
use opchange
to make it a bit easier.
opchange D:/Library/HDRI \$JOB/tex
Now all references to D:/Library/HDRI
should have been replaced with $JOB/tex
.
Gotchas
If you’re swapping a variable, and you want to search for the unexpanded
version, ie. $HIP
, make sure to escape the $
with a \
, otherwise Houdini
will be searching for the expanded version, like ~/project/myproject
instead.
opchange \$HIP \$JOB/hip
Limit the Scope
We don’t have to search the entire scene in this case, since we know that all of
our lights are going to exist at /obj
.
opchange -p /obj D:/Library/HDRI \$JOB/tex
Duplicated a node and want to change the new node’s parm references? use the -i flag.
opchange -i -p /obj/sheepnmoon/mat/fuzz_moon sheep_ moon_