Jump to content

select previously selected node


Recommended Posts

Very often, I need to select previously selected node. Usually because I go upstream and change some parameter, then I want to return back down. Or I want to compare parameters of few nodes and toggle between them.

I just had two ideas how to do that:

1) bind event callback for hou.nodeEventType.ChildSelectionChanged and save my own undo history ... this works, but it is probably bad idea, because I would have to add callback for every node?
2) save selection with putenv (more than one node) and switch between those nodes ... this is fine, when I want just to compare few node's parameters

Please, do you have any idea, how to do it right?

Here is my script which helps me toggle selection between few nodes:


def selection_switch () :
    nodes = hou.selectedNodes()
    count = len(nodes)
    if count > 1 :
        # if few nodes are selected, then initialize, save that selection
        selection_stack = ','.join(node.path() for node in nodes)
        hou.putenv('selection_stack', selection_stack )
        hou.putenv('selection_current', '0' )
        hou.putenv('selection_count'  , str(count) )

    # even if one node is selected...
    selection_stack   = hou.getenv('selection_stack', 'none')
    selection_current = hou.getenv('selection_current', 'none')
    selection_count   = hou.getenv('selection_count', 'none')
    # go to next node...
    stack   = selection_stack.split(',')
    current = int(selection_current) + 1
    count   = int(selection_count)
    if current == count :
        current = 0

    # update the saved variable
    hou.putenv('selection_current', str(current) )

    # select that node in current pane
    target = hou.node(stack[current])
    parm_pane = wf_selection.pane_linkGroup( hou.paneTabType.Parm )


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.

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