Jump to content

edit 'hide when' in 'edit paraemter interface' using python


Lucavfx

Recommended Posts

Hi,

I'd like  to access the 'Hide When' parameter field in 'Edit Parameter Interface' via python. The idea is to access this field and store a string such as "{ showmoreinfo == 1 }". Is there a way to easily do this?

I searched and found workarounds which involve calling the hide method i.e. hou.parm('/out/mantra1/vm_lightexport_scope21').hide(1) but this result in an inefficient system requiring hoops to achieve what I want.

Any ideas?

Thanks

Luca

 

Link to comment
Share on other sites

Disable/Hide When is handled through a parameters ParmTemplate conditionals dict.

Consider this example of a button that is disabled/hidden when a toggle ('parm') is not checked:

>>> pt=hou.parm('/obj/geo1/null1/parm2').parmTemplate()
>>> pt
<hou.ButtonParmTemplate name='parm2' label='Label'>
>>> pt.conditionals()
{parmCondType.DisableWhen: '{ parm == 0 }', parmCondType.HideWhen: '{ parm == 0 }'}
>>> pt.setConditional(hou.parmCondType.DisableWhen, "{ parm == 1 }")
>>> pt.setConditional(hou.parmCondType.HideWhen, "{ parm == 1 }")
>>> pt.conditionals()
{parmCondType.DisableWhen: '{ parm == 1 }', parmCondType.HideWhen: '{ parm == 1 }'}
>>> n.replaceSpareParmTuple(pt.name(), pt)

 

  • Like 1
Link to comment
Share on other sites

23 minutes ago, graham said:

Disable/Hide When is handled through a parameters ParmTemplate conditionals dict.

Consider this example of a button that is disabled/hidden when a toggle ('parm') is not checked:


>>> pt=hou.parm('/obj/geo1/null1/parm2').parmTemplate()
>>> pt
<hou.ButtonParmTemplate name='parm2' label='Label'>
>>> pt.conditionals()
{parmCondType.DisableWhen: '{ parm == 0 }', parmCondType.HideWhen: '{ parm == 0 }'}
>>> pt.setConditional(hou.parmCondType.DisableWhen, "{ parm == 1 }")
>>> pt.setConditional(hou.parmCondType.HideWhen, "{ parm == 1 }")
>>> pt.conditionals()
{parmCondType.DisableWhen: '{ parm == 1 }', parmCondType.HideWhen: '{ parm == 1 }'}
>>> n.replaceSpareParmTuple(pt.name(), pt)

 

 

Thanks, I'm getting closer now. The problem is that as in the case of image plane parameters they're specified as vm_channel_plane# however python param and parmTemplate calls expect parameter names to be explicit (i.e. vm_channel_plane23). Setting the conditionals dict to explicit parameters does not seem to apply in this case

Link to comment
Share on other sites

In the case of something like that (and if say modifying more than one parameter, or the ones on digital assets) you'll want to use the hou.ParmTemplateGroup from the node like as follows:

>>> hou.parm('/out/mantra1/vm_variable_plane1').description()
'VEX Variable'
>>> ptg = hou.node('/out/mantra1').parmTemplateGroup()
>>> ptg.find("vm_variable_plane#")
<hou.StringParmTemplate name='vm_variable_plane#' label='VEX Variable' length=1 naming_sch
>>> pt = ptg.find("vm_variable_plane#")
>>> pt.setLabel("This is a test")
>>> ptg.replace(pt.name(), pt)
>>> hou.node('/out/mantra1').setParmTemplateGroup(ptg)
>>> hou.parm('/out/mantra1/vm_variable_plane1').description()
'This is a test'

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 1/27/2017 at 5:51 PM, graham said:

In the case of something like that (and if say modifying more than one parameter, or the ones on digital assets) you'll want to use the hou.ParmTemplateGroup from the node like as follows:


>>> hou.parm('/out/mantra1/vm_variable_plane1').description()
'VEX Variable'
>>> ptg = hou.node('/out/mantra1').parmTemplateGroup()
>>> ptg.find("vm_variable_plane#")
<hou.StringParmTemplate name='vm_variable_plane#' label='VEX Variable' length=1 naming_sch
>>> pt = ptg.find("vm_variable_plane#")
>>> pt.setLabel("This is a test")
>>> ptg.replace(pt.name(), pt)
>>> hou.node('/out/mantra1').setParmTemplateGroup(ptg)
>>> hou.parm('/out/mantra1/vm_variable_plane1').description()
'This is a test'

 

Thanks Graham that helped quite a bit

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...