Jump to content

Assign user parameter values to variables dynamically


Neronie

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):

	updateSettings()
	extractInfo()

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

def extractInfo():
   [REGEX MATCHING CODE]

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...