Jump to content
Sign in to follow this  
jamesearnest244

Assigning Hotkeys to Shading Modes

Recommended Posts

Hi,

Is there a way to assign hotkeys to specific shading modes in the viewport? I know I can use W to toggle between wireframe and the last selected shading mode, but I'd like to have specific hotkeys for Wireframe Ghost, Flat Wire Shaded, etc. If I use Ctrl+Alt+Shift+LMB, I get a prompt saying the hotkey couldn't be created.

BTW, would also be nice to assign hotkeys to Hide Other Objects/Ghost Other Objects, but I'm seeing the same problem there.

Thanks!

Share this post


Link to post
Share on other sites

Hi,

You can write some Python code and call these functions inside a shelf tool and assign a hotkey to this shelf tool that can be constrained to SceneViewers only or global depending on how you want to execute them.

You can get the viewport under the mouse also. I just get the first available SceneViewer for my workflow.

def currentViewportSetToWireframe():
    with hou.undos.disabler():
        desktop = hou.ui.curDesktop()
        viewport = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
        if viewport.isCurrentTab():
            view = viewport.curViewport()
            displaySet = view.settings().displaySet(hou.displaySetType.DisplayModel)
            displaySet.setShadedMode(hou.glShadingType.WireGhost)



def currentViewportSetToHiddenLineInvisible():
    with hou.undos.disabler():
        desktop = hou.ui.curDesktop()
        viewport = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
        if viewport.isCurrentTab():
            view = viewport.curViewport()
            displaySet = view.settings().displaySet(hou.displaySetType.DisplayModel)
            displaySet.setShadedMode(hou.glShadingType.HiddenLineInvisible)



def currentViewportSetToFlatShaded():
    with hou.undos.disabler():
        desktop = hou.ui.curDesktop()
        viewport = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
        if viewport.isCurrentTab():
            view = viewport.curViewport()
            displaySet = view.settings().displaySet(hou.displaySetType.DisplayModel)
            displaySet.setShadedMode(hou.glShadingType.Flat)



def currentViewportSetToFlatWireShaded():
    with hou.undos.disabler():
        desktop = hou.ui.curDesktop()
        viewport = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
        if viewport.isCurrentTab():
            view = viewport.curViewport()
            displaySet = view.settings().displaySet(hou.displaySetType.DisplayModel)
            displaySet.setShadedMode(hou.glShadingType.FlatWire)



def currentViewportSetToSmoothShaded():
    with hou.undos.disabler():
        desktop = hou.ui.curDesktop()
        viewport = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
        if viewport.isCurrentTab():
            view = viewport.curViewport()
            displaySet = view.settings().displaySet(hou.displaySetType.DisplayModel)
            displaySet.setShadedMode(hou.glShadingType.Smooth)



def currentViewportSetToSmoothWireShaded():
    with hou.undos.disabler():
        desktop = hou.ui.curDesktop()
        viewport = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
        if viewport.isCurrentTab():
            view = viewport.curViewport()
            displaySet = view.settings().displaySet(hou.displaySetType.DisplayModel)
            displaySet.setShadedMode(hou.glShadingType.SmoothWire)

For changing the visibility of other objects, you might have to call an Hscript command in Python.

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
Sign in to follow this  

×