Jump to content
Sign in to follow this  

Assign user parameter values to variables dynamically

Recommended Posts

Hey guys,

Super new to Houdini Python scripting and I've come across a bit of a roadblock.
I'm trying to build an asset to find named textures in a folder to automatically build materials with one click.

What I've got so far works great. I have a button parameter on the HDA which runs the code in the PythonModule, with the following callback script: 

kwargs['node'].hdaModule().onButtonPress(kwargs['node'], kwargs['parm'])

I'm using regular expressions to parse the file names and find the correct textures. I want to add exposed parameters on the HDA so that the user can change what string regex uses for matching if needed (i.e. 'albedo' vs 'diffuse'), and other settings (i.e. whether to load in certain textures or not, what level of detail to use)

I've managed to read in the parameter values using hou.pwd().evalParm(). However, it seems as if the changes to the parameters are only read in when I'm applying the changes from the Type Properties panel. I can't seem to be able to assign parameter values to existing variables with a button press. This is what I'd ideally like to accomplish:

regex_albedo = "Albedo"
regex_bump = "Bump"

def onButtonPress(me, parm):


def updateSettings()
    regex_albedo = hou.pwd().evalParm("regex_albedo")

def extractInfo():

I want the user to be able to click on the Create Material button on my HDA and for the script to parse the current parameter values, THEN execute the code to actually do regex matching and everything else that's supposed to happen. Ideally, if the parameters are empty, the script should fallback to default 'hardcoded' values.

Can someone enlighten me?

Thanks a bunch!!

Edited by Neronie

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this