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 )


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