Last active
January 22, 2021 16:57
-
-
Save kickbase/0883356241b2e90aa5240f09c653edad to your computer and use it in GitHub Desktop.
[Houdini] [Python] Make hipfile a light scene data and save it.
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
def init_and_save(cn): | |
pos = [] | |
path = cn.path() | |
posX = posY = 0 | |
if len(cn.children()) > 0: | |
for node in cn.children(): | |
pos.append(node.position()) | |
posX = sum([x[0] for x in pos]) / len(pos) | |
posY = max([x[1] for x in pos]) | |
if not hou.node(path + "/__INIT"): | |
null = hou.node(path + "/").createNode("null", "__INIT") | |
null.setPosition(hou.Vector2(posX, posY + 1)) | |
else: | |
null = hou.node(path + "/__INIT") | |
null.setDisplayFlag(True) | |
null.setRenderFlag(True) | |
null.setColor(hou.Color((0, 0.5, 1))) | |
hou.hipFile.save() | |
def main(): | |
editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor) | |
current_node = editor.pwd() | |
if current_node.childTypeCategory() == hou.sopNodeTypeCategory(): | |
init_and_save(current_node) | |
main() |
run script in SOP level
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
without hou.selectedNodes()