Little Python Shelf Tools

I have few little python snippets like this, in a shelf. Some of them bound to hotkeys. Btw with the Autohotkey, you can also remap to any Key + Scroll wheel. Thanks goes to the community. I did not built those scripts from scratch, other smart people did (graham, galagast, mestela, and others).

Toggle manual / auto update

Thanks to berniebernie!

import hou
mode = hou.updateModeSetting().name()
if mode == 'AutoUpdate':
    hou.setUpdateMode(hou.updateMode.Manual)
if mode == 'Manual':
    hou.setUpdateMode(hou.updateMode.AutoUpdate)

Activate OpenCL on all subchildren

for node in hou.selectedNodes():
    for subnode in node.allSubChildren():
        for p in subnode.parms():
            if p.name()=='opencl':
                try:
                    p.set(1)
                except hou.PermissionError: 
                    pass

Scope all animated channels

nodeArr = hou.node("/").allSubChildren()
for n in nodeArr:
    if not n.isInsideLockedHDA():
        parmArr = n.parms()
        for p in parmArr:
            if p.isTimeDependent():
                p.setScope(1)

Toggle Display points with global hotkey

pane = hou.ui.curDesktop().paneTabOfType(hou.paneTabType.SceneViewer)
settings = pane.curViewport().settings()
markersDisplayModel = settings.displaySet(hou.displaySetType.DisplayModel)
markersSceneObject = settings.displaySet(hou.displaySetType.SceneObject)

# Toggle the markers (visible when inside /obj/...)
markersDisplayModel.showPointMarkers(not markersDisplayModel.isShowingPointMarkers())

# Unify with the scene (visible when in top level "/obj")
markersSceneObject.showPointMarkers(markersDisplayModel.isShowingPointMarkers())

Little snippets to navigate the network view with kbd

# hotkey alt-shift-r
hou.playbar.setRealTime(not hou.playbar.isRealTime())

# hotkey ctrl-ins
for node in hou.selectedNodes():
    node.setRenderFlag(not node.isRenderFlagSet())

# hotkey ins
for node in hou.selectedNodes():
    node.setDisplayFlag(not node.isDisplayFlagSet())

# hotkey ctrl-del
for node in hou.selectedNodes():
    node.bypass(not node.isBypassed())

# hotkey ctrl-shift-ins
for node in hou.selectedNodes():
    node.setTemplateFlag(not node.isTemplateFlagSet())

# hotkey Z
pane = hou.ui.curDesktop().paneTabOfType(hou.paneTabType.SceneViewer)
pane.curViewport().frameSelected()

# hotkey shift-Z
pane = hou.ui.curDesktop().paneTabOfType(hou.paneTabType.SceneViewer)
pane.curViewport().frameAll()

Leave a Reply

Your email address will not be published. Required fields are marked *