Created
June 28, 2021 06:29
-
-
Save baku89/024b63cb9c139c793c906630fd9e06d5 to your computer and use it in GitHub Desktop.
RAM Preview.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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