Hi
I need to change the node type in several nodes, I am taking about an HDA, I have to replace them by another simuilar one, same parameters, but different content.
I can´t find a method to do it in the hou.Node documentation.
there is a method to swap the node type? .. or change the version of an HDA.
Thanks
python: change node type
670 3 1- Gerardo Castellanos
- Member
- 55 posts
- Joined: March 2016
- Offline
- dedeks2999
- Member
- 87 posts
- Joined: May 2011
- Offline
https://www.sidefx.com/docs/houdini/hom/hou/OpNode.html [www.sidefx.com]
Look at the changeNodeType() Method...
Look at the changeNodeType() Method...
— dedeks 3000 —
- mapoga
- Member
- 10 posts
- Joined: Feb. 2017
- Offline
Here is a possible solution.
Keep in mind that this is a naive approach since an hda file can contain multiple definitions.
I would be interested to know if someone has a better way.
Keep in mind that this is a naive approach since an hda file can contain multiple definitions.
I would be interested to know if someone has a better way.
import hou def replace_type_instances(src_type, dst_type): for instance in src_type.instances(): if instance.isEditableInsideLockedHDA(): keep_network_contents = not instance.matchesCurrentDefinition() new_node = instance.changeNodeType( dst_type.name(), keep_parms=True, keep_network_contents=keep_network_contents ) def get_hda_first_type(hda_filepath): definitions = hou.hda.definitionsInFile(hda_filepath) for definition in definitions: return definition.nodeType() def main(): src_type = get_hda_first_type('/path/to/src.hda') dst_type = get_hda_first_type('/path/to/dst.hda') if src_type and dst_type: dst_type.definition().setIsPreferred(True) with hou.undos.group('Replace type instances'): replace_type_instances(src_type, dst_type) main()
- Gerardo Castellanos
- Member
- 55 posts
- Joined: March 2016
- Offline
-
- Quick Links