Skip to content

Instantly share code, notes, and snippets.

@kickbase
Last active January 22, 2021 16:57
Show Gist options
  • Save kickbase/0883356241b2e90aa5240f09c653edad to your computer and use it in GitHub Desktop.
Save kickbase/0883356241b2e90aa5240f09c653edad to your computer and use it in GitHub Desktop.
[Houdini] [Python] Make hipfile a light scene data and save it.
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()
@kickbase
Copy link
Author

without hou.selectedNodes()

@kickbase
Copy link
Author

run script in SOP level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment