Jump to content

Hide parameters through python


Andrea

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?

Link to comment
Share on other sites

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
Link to comment
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 :) 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 2 weeks later...

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

 

 

Link to comment
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

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