Jump to content
Andrea

Hide parameters through python

Recommended Posts

Hey guys!

I'm creating a python script in an HDA. When the hda is created, this node is also going to create a null at /obj level and adds some parameters.

What I don't like is that parameters that we usually find in this kind of null has not a clean interface but has already some parameters by default.

I am trying to hide them using the suggested code https://www.sidefx.com/forum/topic/30708/. Using the following code I can hide one of the parameters (xOrd). 

 

##### CREATING CONTROL NULL ######
##################################

def control(node, parms):
    import hou
    
    creation_place = hou.node("/obj")
    null = creation_place.createNode('null','CONTROL')
    
    ### HIDE INTERFACE OF NULL
    null_tg = null.parmTemplateGroup()
    copy_parm_template = null_tg.find(“xOrd”)
    null_tg.hide(copy_parm_template, True)

    #setting the template
    null.setParmTemplateGroup(null_tg)

 

What I would like to do is to loop through all the parameters/folders and hide them all. But if I loop through all the parameters using null.parms() I am not able to make it work the hide function. Any hints?

Share this post


Link to post
Share on other sites
Posted (edited)

Hi!

This should work:

creation_place = hou.node("/obj")
null = creation_place.createNode('null','CONTROL')

### HIDE INTERFACE OF NULL
null_tg = null.parmTemplateGroup()
null_tg.hideFolder("Transform",True)
null_tg.hideFolder("Render",True)
null_tg.hideFolder("Misc",True)

#setting the template
null.setParmTemplateGroup(null_tg)

 

Edited by LucaScheller
  • Thanks 1

Share this post


Link to post
Share on other sites

Hi Luca!

Thank you so much! It works perfectly

Curious to see that you are calling the folders by their label and not by their name. I'm very new to this kind of stuff but I was so sure that functions need to reference to parameters and folders by their label only if we specifically look for them. Good to know I was wrong :) 

Share this post


Link to post
Share on other sites
Posted (edited)
16 minutes ago, Andrea said:

Hi Luca!

Thank you so much! It works perfectly

Curious to see that you are calling the folders by their label and not by their name. I'm very new to this kind of stuff but I was so sure that functions need to reference to parameters and folders by their label only if we specifically look for them. Good to know I was wrong :) 

Actually this was the first time I looked up on how to do this. I was really surprised that you have to use labels too instead of parm names, pretty unusual. :huh: Maybe I'm doing it wrong xD  But it works, so ;)

Edited by LucaScheller

Share this post


Link to post
Share on other sites

just so you know and go crazy like I did,

one issue with doing that with python is that parms hidden won't stay hidden across sessions.
This is also the case with disabled parms. This issue is never going to be fixed.
A workaround is to create a hidden toggle for driving the expressions 'Disable When' and 'Hide When' for each parm you need to hide/disable. I really don't like this workaround, but it seems the only option if you really need consistency across sessions?

Quoting from the Support:
 

Quote

I am told the 'disable' and 'hide' parameter states are meant to be dynamic and controlled by scripts. They are both controlled by "disable when" and "hide when" expressions, and the HOM functions are provided to expose this functionality to other dynamic scripts.
Therefore, they have never been saved since the dawn of Houdini, and for backwards consistency and compatibility never will be.

cleardot.gif

 

 

Share this post


Link to post
Share on other sites

Thanks for letting me know ahead! I haven't encountered this issue yet, so I haven't spent much time solving it.

 

Luckily in my case I can also just create a folder for all the parameters created by python but definitely would have been much cleaner to hide the parameters in a standard way, without workarounds

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×