Alex Doss

VFX TD | Generalist

On the Edit Operator Type properties > Scripts tab, make sure you have created a Python Module on the left hand side of the window, and you are editing it as Python on the right hand side.

That’s where you can define all your custom functions. 

On your parameter, in the Parameters tab, set the callback field to Python, if not set already.

kwargs[‘node’] is the same as hou.pwd()

Passing kwargs to the custom function is optional but good practice. Its a dictionary with relevant info to retrieve on a callback. 

alternatively:
__import__(“myExternalFile”).myFunc( kwargs )
Works so long as the file “myExternalFile.py” exists in $PYTHONPATH

In that case, you’d be bypassing the hdaModule(). Just be sure to reload the module each time you update the external file:

python 2.x:
reload(module)

python 3.4 or above:
import importlib
importlib.reload(module)