Set NetworkEditor path to NetworkBox or StickyNote

   1476   5   1
User Avatar
Member
28 posts
Joined: Nov. 2016
Offline
Hi,

I'm trying to move the network editor and center it on NetworkMovableItem objects other than Node.

Moving it towards a Node object works fine with:

hou.ui.curDesktop().paneTabOfType(hou.paneTabType.NetworkEditor).setCurrentNode(node)

I can't figure out how to do that with StickyNote or NetworkBox objects since all available functions seem to only work with nodes.
Edited by gorrod - Oct. 31, 2020 13:59:58
User Avatar
Member
4500 posts
Joined: Feb. 2012
Online
Hi,

You can do something like this:

stickynode = hou.item("/obj/geo1/__stickynote2")

def centerNetworkEditor(editor, center):
    bounds = editor.visibleBounds()
    bounds.translate(center - bounds.center())
    editor.setVisibleBounds(bounds)
    
editor = hou.ui.curDesktop().paneTabOfType(hou.paneTabType.NetworkEditor)
center = stickynode.position() + (stickynode.size() / 2)
centerNetworkEditor(editor, center)
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
28 posts
Joined: Nov. 2016
Offline
Hi,
thanks animatrix_ for the suggestion.

I'm doing this already for centering the view, but if the stickynote is on another path this just moves your current network to that location. (e.g. youre in a COP network and the stickynote is on some other SOP level).

How do I tell the networkeditor to move to that new path? (e.g. “/img/comp1/” to “/obj/geo1/”)
Only way I was able to do it is creating a node inside the network I want to go in, set as current and then delete it.
This is obviously not a great idea.

A better phrasing of my question would basicly be: “How can I dive inside of a network with python?”
Edited by gorrod - Nov. 1, 2020 05:18:11
User Avatar
Member
28 posts
Joined: Nov. 2016
Offline
Phrasing the question in a better way actually resolved the issue for me.

Using animatrics code the answer to my question would be to do something like this:

stickynode = hou.item("/obj/geo1/__stickynote1")

def centerNetworkEditorOnItem(editor, item):
    center = item.position() + (item.size() / 2)
    bounds = editor.visibleBounds()
    bounds.translate(center - bounds.center())
    
    editor.cd(item.parent().path())
    editor.setVisibleBounds(bounds)
    
editor = hou.ui.curDesktop().paneTabOfType(hou.paneTabType.NetworkEditor)
centerNetworkEditorOnItem(editor, stickynode)

I didn't take the hou.PathBasedPaneTab.cd() [www.sidefx.com] function into account since it is not yet documented (Probably because it should be obvious what it does?).
Edited by gorrod - Nov. 1, 2020 05:43:51
User Avatar
Member
4500 posts
Joined: Feb. 2012
Online
I see what you mean now. You can also use setPwd instead of cd.

I wrote this code for a similar function to have a custom jump up function that can go above the allowed top level context to the contextless level:

def jumpUpOneLevel():
    with hou.undos.group("Jump Up"):
        currentPaneTab = hou.ui.paneTabUnderCursor()
        if currentPaneTab:
            pwd = currentPaneTab.pwd()
            parentNode = pwd
            if pwd.isInsideLockedHDA():
                parent = pwd
                hdadef = None
                while hdadef is None and parent:
                    hdadef = parent.type().definition()
                    if hdadef is None:
                        parent = parent.parent()

                if hdadef:
                    sections = hdadef.sections()
                    if "DiveTarget" in sections:
                        diveTarget = sections["DiveTarget"].contents()
                        parentNode = parent

            parentNode = parentNode.parent()
            if parentNode:
                currentPaneTab.setPwd(parentNode)
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
28 posts
Joined: Nov. 2016
Offline
I see, now it makes sense .

Thanks for the example, that's great to know.
  • Quick Links