Skip to content

Instantly share code, notes, and snippets.

@baku89
Created June 28, 2021 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baku89/024b63cb9c139c793c906630fd9e06d5 to your computer and use it in GitHub Desktop.
Save baku89/024b63cb9c139c793c906630fd9e06d5 to your computer and use it in GitHub Desktop.
RAM Preview.py
# Requires to place Viewport Preview ROP (https://github.com/baku89/nops/blob/main/otls/viewport_preview.hdalc)
# on the OBJ context
def getCurrentNetworkEditorPane():
editors = [pane for pane in hou.ui.paneTabs() if isinstance(pane, hou.NetworkEditor) and pane.isCurrentTab() and pane.pwd().path().startswith("/obj")]
if len(editors):
return editors[0]
pane = getCurrentNetworkEditorPane()
ram_rop = None
if pane:
node = pane.pwd()
# Search Ancestor
while node is not None:
cat = node.type().childTypeCategory().name()
if cat == 'Object':
rops = node.recursiveGlob('*', hou.nodeTypeFilter.Rop, False)
rops = [rop for rop in rops if rop.type().name() == 'viewport_preview']
if len(rops) > 0:
ram_rop = rops[0]
break
# Next
node = node.parent()
if node == hou.root():
break
if ram_rop == None:
hou.ui.displayMessage("No Rop for RAM preview is found")
else:
ram_rop.parm('preview_from_current').pressButton()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment