Jump to content

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!

Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...