Jump to content
younglegend

opunhide all nodes using python

Recommended Posts

How do you opunhide all nodes in a particular category or a bunch of specific nodes using python? I wish to add this in my startup script.

a simple hou.hscriptExpression("opunhide Sop point") dosent seem to work. Nor does hou.hscript(). What am i doing wrong?

 

Share this post


Link to post
Share on other sites
11 minutes ago, younglegend said:

Nor does hou.hscript()

hou.hscript("opunhide Sop point")

should work

  • Thanks 1

Share this post


Link to post
Share on other sites
23 minutes ago, anim said:

hou.hscript("opunhide Sop point")

should work

oh you're right, it does. Had to restart houdini for some reason.

ok so hou.hscript("opunhide Sop") gives me all the hidden sop nodes but since it's returns a string, how do you make it a list so that i can loop for each node and say hou.hscript("opunhide Sop <node_name>")

 

sop_list = []
for i in hou.hscript("opunhide Sop"):
    sop_list.append(str(i))

for sop in _sop_list:
  node _name = (sop.split(" ")[-1])
  print node_name

This won't work as i realized t's returning a string, not list of nodes  :blink:

Share this post


Link to post
Share on other sites
sop_list = hou.hscript("opunhide Sop")[0].split()[2::3]
for sop in sop_list:
    hou.hscript("opunhide Sop {}".format(sop))

or if you want to unhide all nodes of all types

all = hou.hscript("opunhide")[0].split()
node_list = [all[i+1:i+3] for i in range(0, len(all), 3) ]
for node in node_list:
    hou.hscript("opunhide {} {}".format(node[0], node[1]))
Edited by anim

Share this post


Link to post
Share on other sites
1 hour ago, anim said:

sop_list = hou.hscript("opunhide Sop")[0].split()[2::3]
for sop in sop_list:
    hou.hscript("opunhide Sop {}".format(sop))

or if you want to unhide all nodes of all types


all = hou.hscript("opunhide")[0].split()
node_list = [all[i+1:i+3] for i in range(0, len(all), 3) ]
for node in node_list:
    hou.hscript("opunhide {} {}".format(node[0], node[1]))

That's perfect. Thanks Tomas ^_^

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

×