Jump to content
Sign in to follow this  
eunchae

Please tell me how to select the parent node by script.

Recommended Posts

Posted (edited)

Hi.

I want to select all the parent nodes of the selected node.

For example, if you select null3 and click the Python shelf, the parent node null2 is selected, and if you press the Python shelf again, the parent node above it is selected, and all the parent nodes are selected.

 

Please refer to the image.

Please check my script.

Thank you.

 

node = hou.selectedNodes()[0]
b= node.inputs()[0]
b.setSelected(True)

 

setSelected_ex.jpeg

setSelected_ex2.JPG

Edited by eunchae

Share this post


Link to post
Share on other sites
On 20/04/2020 at 12:42 PM, eunchae said:

Hi.

I want to select all the parent nodes of the selected node.

For example, if you select null3 and click the Python shelf, the parent node null2 is selected, and if you press the Python shelf again, the parent node above it is selected, and all the parent nodes are selected.

 

Please refer to the image.

Please check my script.

Thank you.

 


node = hou.selectedNodes()[0]
b= node.inputs()[0]
b.setSelected(True)

 

setSelected_ex.jpeg

setSelected_ex2.JPG

This is so similar to what I am trying to do also; I need a button to select a specific node from another location directory.

Share this post


Link to post
Share on other sites
nodes = hou.selectedNodes()
for i in nodes:
    i.inputs()[0].setSelected(True)

I didn't fully understand what you need exactly but if you want to select all the parent nodes by clicking multiple times for python shelf button this will work.

nodes = hou.selectedNodes()
for i in nodes:
    foo = i.inputs()
    if(len(foo)!=0):
        i.inputs()[0].setSelected(True, clear_all_selected=True)

 If you want to select the parent node and clear the selected node before this will work. This will leave only one selected node, the script before leave multiple selected nodes.

Share this post


Link to post
Share on other sites
On 2020. 4. 25. at 4:45 AM, msmahesh said:

nodes = hou.selectedNodes()
for i in nodes:
    i.inputs()[0].setSelected(True)

I didn't fully understand what you need exactly but if you want to select all the parent nodes by clicking multiple times for python shelf button this will work.


nodes = hou.selectedNodes()
for i in nodes:
    foo = i.inputs()
    if(len(foo)!=0):
        i.inputs()[0].setSelected(True, clear_all_selected=True)

 If you want to select the parent node and clear the selected node before this will work. This will leave only one selected node, the script before leave multiple selected nodes.

Thank you!!

 

node = hou.selectedNodes()[-1]

sel_list = []

b= node.inputs()[0]

sel_list.append(b)

b.setSelected(True)

I tried this Thank you very much for the answer.

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
Sign in to follow this  

×