Skip to content

Instantly share code, notes, and snippets.

@motoishmz
Last active April 19, 2022 07:05
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 motoishmz/50c0ec80187b3a969eb15f028fea42c1 to your computer and use it in GitHub Desktop.
Save motoishmz/50c0ec80187b3a969eb15f028fea42c1 to your computer and use it in GitHub Desktop.
Creates `geo/object_merge` with the selected Null nodes such as `OUT_MyObject` #Houdini
"""
- Select Null node(s)
- Run this script
- New geo(s) consists of `object_merge` which imports the selected Null node are created on /obj. The geo name would be the selected Null node name with removing prefix `OUT_`.
"""
def create_object_merge(selected_node):
prefix = "OUT_"
if selected_node.name() == prefix:
print("create_object_merge error: the node name must not be `OUT_`")
return
new_geo_name = selected_node.name().replace(prefix, "")
new_geo_path = "/obj/{}".format(new_geo_name)
if hou.node(new_geo_path) is None:
new_geo = hou.node("/obj").createNode("geo", new_geo_name)
new_geo.moveToGoodPosition()
new_object_merge = new_geo.createNode("object_merge", "object_merge1")
param_object_path = hou.parm("{}/objpath1".format(new_object_merge.path()))
param_object_path.set(selected_node.path())
print("create_object_merge done: A new geo {} is created".format(new_geo.path()))
else:
print("Already exists: {}".format(new_geo_path))
return
def main():
selected_nodes = hou.selectedNodes()
null_nodes = list(filter(lambda x: x.type().name().lower() == "null", selected_nodes))
if not null_nodes:
print("create_object_merge aborted: No Null node(s) are selected")
else:
[create_object_merge(x) for x in null_nodes]
return
###
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment