setConditional(type, conditional)

   2791   4   0
User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
Hi,

Need help to fill this python function:
setConditional(type, conditional) from parmTemplate()

Tried to fill by setConditional(hou.parmCondType.DisableWhen, ‘{ range != 0 }’) set without any error but it is not work, and look like something wrong with conditional expression.
I don`t know how to write correct condition.

If I write this ({ range != 0 }) expresiion by hand in field “Desable When” - it works.

Any body knows ?

Best Regards
Ostap
User Avatar
Member
16 posts
Joined: March 2016
Offline
If you print parmTemplate.conditionals(), does it show “{parmCondType.DisableWhen: ‘{range != 0}’}”? If so, then the parmTemplate is being set correctly, but it might be a matter of updating the parmTemplateGroup to reflect the changes.
Edited by VFXLife - Jan. 17, 2017 19:42:36
User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
Hi,
Thanks for your feedback.

This is my code example:
n=hou.node('/obj/').createNode(“geo”, “test_condition”)
n.parm(“ty”).parmTemplate().setConditional(hou.parmCondType.DisableWhen, ‘{ tx == 0 }’)
n.updateParmStates()
n.parm(“ty”).parmTemplate().conditionals()
>>>
{}

But when I use one more temp variable, conditionals() will show correct result.

pt=n.parm(“ty”).parmTemplate()
pt.setConditional(hou.parmCondType.DisableWhen, ‘{ tx == 0 }’)
pt.conditionals()
>>>
{parmCondType.DisableWhen: ‘{ tx == 0 }’}

In both cases I don`t have any feedback to UI.

Maybe is it some bug ? Tested 15.5.717 build
User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
Found:
The parmTemplate() function returns a *COPY* of the parameter's template so modifying it won't do anything.
https://houdinitricks.com/adding-parameters-to-the-interface-via-python/ [houdinitricks.com]
User Avatar
Member
1904 posts
Joined: Nov. 2006
Offline
Someone asked a similar question on odforce today that reminded me I never responded to this post.

You're correct in that hou.Parm.parmTemplate() returns a copy so you must then replace that node's version with yours as described in the last line of the code example from the odforce post.


http://forums.odforce.net/topic/28700-edit-hide-when-in-edit-paraemter-interface-using-python/ [forums.odforce.net]
Graham Thompson, Technical Artist @ Rockstar Games
  • Quick Links