Last active
April 9, 2023 09:43
-
-
Save digitaldosyanich/8a31b0900bf9a4d80c2adddc9adab13a to your computer and use it in GitHub Desktop.
[Houdini] [Python] Swap the Template and Display flags on two differen nodes in current SOP
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
#created/tested for H.19.5 py3.7 | |
import hou | |
def swap_flags(): | |
editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor) | |
current_node = editor.pwd() | |
if current_node and current_node.childTypeCategory() == hou.sopNodeTypeCategory(): | |
display_node = None | |
template_node = None | |
for child in current_node.children(): | |
node = hou.node(child.path()) | |
if "setTemplateFlag" in dir(node) and "setDisplayFlag" in dir(node): | |
if node.isTemplateFlagSet(): | |
template_node = node | |
elif node.isDisplayFlagSet(): | |
display_node = node | |
if display_node is not None and template_node is not None: | |
template_node.setTemplateFlag(False) | |
template_node.setDisplayFlag(True) | |
template_node.setRenderFlag(True) | |
display_node.setDisplayFlag(False) | |
display_node.setRenderFlag(False) | |
display_node.setTemplateFlag(True) | |
hou.ui.setStatusMessage("Flags swapped successfully.") | |
else: | |
hou.ui.setStatusMessage("Could not find nodes with display and template flags.") | |
else: | |
hou.ui.setStatusMessage("Please select a geometry node in the network editor.") | |
swap_flags() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment