hou.phm() in event handlers

phm() → hou.HDAModule

“This shortcut lets you write hou.phm() instead of hou.pwd().hdaModule(). You are most likely to use this shortcut from event handlers, button callbacks, and menu generation scripts in digital assets.”

It is Houdini’s Help.
But phm() and hou.pwd().hdaModule() do not work in event handlers.

Use instead in event handlers:

kwargs['node'].hdaModule().foo()

Print filenames from Nuke

It’s a simple python script to print filenames in all Write nodes from Nuke:

print "========================"
for node in nuke.allNodes():
    if 'Write' in node['name'].value():
        print node['file'].value()

To run this script you can save it to file .py and run from File/Run Script menu (Alt + X).
The result will be printed in the Script Editor (right click to any content menu, Windows/Script Editor).

You can change Write to Read to print all comp’s references:

print "========================"
for node in nuke.allNodes():
    if 'Read' in node['name'].value():
        print node['file'].value()

To find the filenames with specific location run next script:

print "========================"
location = '/LOCATION_PATH/'
for n in nuke.allNodes():
    if 'Read' in n['name'].value() or 'Write' in n['name'].value():
        if location in n['file'].value():
            print n['file'].value()

Pre-render create directory

Custom parameter (shader_node) with path to node with filename parameter (if You use it in shader etc.):

`opfullpath("/obj/geo_heating/shopnet/material_bake/heating_pc_v001")`

Pre-render script to create non-existent directory:

import os
path = hou.pwd().parm('shader_node').evalAsString()
dirName = os.path.dirname(hou.node(path).parm('filename').evalAsString())
if not os.path.exists(dirName):
    os.makedirs(dirName)

Scale Packed Geometries

This is a simple VEX code that allows you to change the size of objects:

matrix3 xform = primintrinsic(0, "transform", @primnum);
scale(xform, chf("scale"));
setprimintrinsic(0, "transform", @primnum, xform);