Open1
Houdini Parameter Template
import hou
REF = hou.node('/obj/reference')
def get_modified_parm_dict(reference, path):
parm_path = {}
for node in (reference.children()):
parm_path.update({ parm.path(): parm.eval() for parm in node.parms() if parm.isAtDefault() == False })
parm_path = {key.replace(reference.path(), path): value for key, value in parm_path.items()}
return parm_path
def add_nodes(s_node, reference, count):
if count == len(reference):
s_node.setGenericFlag(hou.nodeFlag.Display, True)
return
s_node = s_node.createOutputNode(reference[count].type().name())
return add_nodes(s_node, reference, count + 1)
def main(roots, reference):
for root in roots:
for t_geo in root.allSubChildren():
if t_geo.type().name()=='geo':
add_nodes(t_geo.children()[0],reference.children(), 1)
parm_path = get_modified_parm_dict(reference, t_geo.path())
for path, value in parm_path.items():
hou.parm(path).set(value)
nodes = hou.selectedNodes()
alembic_type_node = [node.type().name() for node in nodes if node.type().name() == 'alembicarchive']
non_alembic_type_node = [node.type().name() for node in nodes if node.type().name() != 'alembicarchive']
if len(alembic_type_node) > 0 and len(non_alembic_type_node) == 0:
main(nodes, REF)
else:
hou.ui.displayMessage('Choose "alembicarchive" type node')