eunchae Posted April 20, 2020 Share Posted April 20, 2020 (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) Edited April 20, 2020 by eunchae Quote Link to comment Share on other sites More sharing options...
RustyMac2020 Posted April 24, 2020 Share Posted April 24, 2020 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) 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. Quote Link to comment Share on other sites More sharing options...
msmahesh Posted April 24, 2020 Share Posted April 24, 2020 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. Quote Link to comment Share on other sites More sharing options...
eunchae Posted April 27, 2020 Author Share Posted April 27, 2020 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.