Frame Selection after loading items from file

   255   1   1
User Avatar
Member
696 posts
Joined: 3月 2009
Offline
Hi,

I have python panel with some presets I'm loading from file into the obj context. I then created a callback function to frame the loaded nodes in the network editor. The call back function runs but the network editor doesn't frame the selected nodes for some reason.

Here's my code:
def read_template(template_file):
    root = hou.node("/obj")
    def zoom_selected(node, event_type, **kwargs):
        print(kwargs) # just to check function is being called
        hou.ui.paneTabOfType(hou.panetabType.NetworkEditor).frameSelection()
        root.removeEventCallback((hou.nodeEventType.SelectionChanged, hou.nodeEventType.ChildCreated), zoom_selected)
    root.addEventCallback((hou.nodeEventType.SelectionChanged, hou.nodeEventType.ChildCreated), zoom_selected)
    root.loadItemsFromFile(template_file)
    return 0

Both the print and remove callback statements are called and work, though frameSelection doesn't do anything.
Appreciate any pointers!
Cheers,
Edited by rafaels - 2024年3月6日 08:38:42
Toronto - ON
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
User Avatar
Member
696 posts
Joined: 3月 2009
Offline
Problem solved with a timer that offsets the home to selection by a few milliseconds... feels a bit dirty, but it works!
Toronto - ON
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
  • Quick Links