melazoma Posted February 20, 2009 Share Posted February 20, 2009 Hi all, I'm trying to figure out how to determine if a parameter is at its default value in python.\ The goal is to ignore a parameter if it's at default. Methods of node.parm has revertToDefaults() that actually reverts the parm back to default--which is not what I'm trying to do. I'm not seeing other likely candidates in the intellisense. Where is the default parm value method hiding? Quote Link to comment Share on other sites More sharing options...
graham Posted February 20, 2009 Share Posted February 20, 2009 (edited) Unfortunately there is currently no quick way to determine if a parameter is at it's default value. It's an existing RFE. You can hack it by doing some magic involving the hou.ParmTemplate from the parm though. Unfortunately this method involves evaluating each parm so that can cause slowdown if they require significant time to evaluate. Something like this can give you what you want. def isParmDefaultValue(parm): # Get the parm tuple so we can access the names of all the parms in the group. parm_tuple = parm.tuple() # Get a list of the parm names. parm_names = [p.name() for p in parm_tuple] # Find the index of our parm in the tuple. idx = parm_names.index(parm.name()) # Use the index to get the correct default value. default_value = parm_tuple.parmTemplate().defaultValue()[idx] # Return whether the current value is equal to the default value. return parm.eval() == default_value You can also take it a step further and add the declaration into something like your pythonrc.py file, replace the "parm" variable name with "self" and outside the declaration do something like hou.Parm.isDefaultValue = isParmDefaultValue. This way you can just call isDefaultValue from your hou.Parm instance. Edited February 20, 2009 by graham Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.