el_diablo
I haven't tried but if you set preferred and then force sync, maybe you'll get the version right. Also https://www.sidefx.com/docs/houdini/hom/hou/Node [sidefx.com] , syncNodeVersionIfNeeded(version) might do the trick.
Thanks, that was a good idea. I've been working the code a bit more and now I'm stuck in a same-but-different scenario. Now what happens is this:
> Start with myAsset::1.02, also has versions 1.00 and 1.01 in operator type library
> Run my script to downgrade to myAsset::1.01
- changeNodeType to myAsset::1.01
- set 1.01 as preferred
- uninstall 1.02
- matchCurrentDefinition, syncNodeVersionIfNeeded
> node becomes myAsset::1.00
Instead of being a blank option, now the Asset Name dropdown is set to 1.00 instead of 1.01, even though I'm making sure to have 1.01 set as preferred and 1.01 is the latest definition on disk etc.
What am I doing wrong?
Here's the relevant parts of the script (variable names changed to make it obvious):
def revertHDA():
node = hou.selectedNodes()[-1]
v1.02_definition = node.type().definition()
v1.01_definition = hou.hda.definitionsInFile(old_hda)[-1]
v1.01_definition_name = v1.01_definition.nodeTypeName()
reverted_node = node.changeNodeType(new_node_type=v1.01_definition_name,
keep_network_contents=False,
force_change_on_node_type_match=True)
v1.01_definition.setIsPreferred(True)
hou.hda.uninstallFile(v1.02)
if reverted_node.isLockedHDA():
reverted_node.allowEditingOfContents()
reverted_node.matchCurrentDefinition()
reverted_node.syncNodeVersionIfNeeded(v1.02)
os.remove(v1.02_hda)