Jump to content

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


eunchae

Recommended Posts

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

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

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

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