HOM: Is a Parameter Set to Defaut Value?

   2367   1   0
User Avatar
Member
133 posts
Joined: July 2005
Offline
Hey All:

I am trying to loop through all the parameters on a node to determine whether it's current value is the default. Unfortunately, it seems that there is no such isDefault() method to determine this. So, I started to write my own.

To make matters more complicated, eval() does not yield the same result a defaultValue().

Watch this!

n = hou.node('/obj/foo') # foo object is a geo
parm_tuples = n.parmTuples() # Get all the parm tuples on the geo.
parm = n.parmTuples() # Get the ‘keeppos’ parm, which is a bool.
parm_template = parm.parmTemplate() # This is a hou.ToggleParmTemplate object

parm_template.defaultValue() # Returns True or False
parm.eval() # Returns a tuple!!! (0, )

This makes it hard to compare a parameter's current value with the default value, since they are different types. I have to go through some ugly conversion logic to compare the two values.

Is there a better way?
Francisco Rodriguez
Effects Animator | Walt Disney Animation Studios
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
Python is the suck for figuring this out. I tried to write this long ago (http://houdinitoolbox.com/houdini.php?asset=15) [houdinitoolbox.com] except it fails under various circumstances (which I can't remember and never really bothered to fix). I made some improvements elsewhere but nothing ever really worked super reliably.

The best thing is really to use inlinecpp.py/HOMextendLibrary() (if it's an option). PRM_Parm::isDefault() is the winner. Something as simple as this:
bool
isParmDefault(OP_Node *node, const char *parm_name, int index)
{
PRM_Parm &parm = node->getParm(parm_name);

// If we have a specific index, check if that parm is at its default.
if (index != -1)
{
return parm.isDefault(index);
}

// If not we check if the entire parm is at the default value.
return parm.isDefault();
}
I managed to find RFE: #32476 to properly get the default value of a parameter, though I don't know if I ever had one to check if a parm was at default
Graham Thompson, Technical Artist @ Rockstar Games
  • Quick Links