Jump to content
skyros

Switching Views using python/hscript

Recommended Posts

I'm in the middle of making an otl for our artists and was wondering if there is a way to switch Houdini's viewport panes between Scene View and Composite View.  I haven't found the proper help files for manipulating Houdini's layout through scripting.

Thanks

Mike

Share this post


Link to post
Share on other sites

I think you can do it with the hou.ui module using the pane classes,  last time I tried though(month or so ago) most of the pane functions crashed Houdini so I never really did much with it.

Share this post


Link to post
Share on other sites

You'll need to iterate through the pane tabs in the current desktop to find one whose type is SceneViewer, then:

hou.curDesktop().paneTabs()[ index_of_viewort_tab ].setType( hou.CompositorViewer)

Share this post


Link to post
Share on other sites

Thanks for the heads up Mark.  That was enough for me to search around a little more in the help files.

I have to say I found referencing UI elements a bit confusing since there seem to be several ways to look up different elements.  I ended up changing 'setType' to 'setIsCurrentTab', since I didn't want to actually change the tab but rather which one was selected.  If you have some thoughts on how I could improve this I would appreciate it.

 

import hou

class TabSwitch:
    """
    Switch viewport tabs based on user input
    """
    
    def __init__(self):
        self.comp       = hou.paneTabType.CompositorViewer
        self.scene      = hou.paneTabType.SceneViewer
    
    def getTab(self, tab):
        paneTabs = hou.ui.paneTabs()
        for pt in paneTabs:
            if(pt.type() == tab):
                pt.setIsCurrentTab()    
                              
ts = TabSwitch()       
ts.getTab(ts.comp)

 

 

Edited by skyros

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

×