{"id":704,"date":"2023-09-19T05:41:48","date_gmt":"2023-09-19T12:41:48","guid":{"rendered":"http:\/\/fx-td.com\/houdiniandchill\/?p=704"},"modified":"2023-09-19T05:58:48","modified_gmt":"2023-09-19T12:58:48","slug":"archived-post-by-colemapt96","status":"publish","type":"post","link":"http:\/\/fx-td.com\/houdiniandchill\/2023\/09\/19\/archived-post-by-colemapt96\/","title":{"rendered":"Archived post by Colemapt96"},"content":{"rendered":"<div class=\"postie-post\">\n<p class=\"\">&#8220;`import hou<br \/>\ndef lock_hda(node_path):     &#8220;&#8221;&#8221;     Lock the HDA at the given node path. And then Unlock it now that it has been matched     &#8220;&#8221;&#8221;     # Get the node     node = hou.node(node_path)<br \/>\n    # Check if node exists     if node is None:         print(&#8220;Node does not exist.&#8221;)         return<br \/>\n    # Lock the HDA     node.matchCurrentDefinition()     # Unlock the HDA     node.allowEditingOfContents()<br \/>\n# Example usage def otherDefinitions(node_path):     &#8221;&#8217;Given an HDADefinition object, return the other loaded definitions        for the same node type.&#8221;&#8217;     # Look through all the loaded hda files for definitions providing     # the same node type.     node = hou.node(node_path)     definition = node.type().definition()     node_version = definition.nodeTypeName().split(&#8216;::&#8217;)[0]     result = []     result.append(definition)     for hda_file in hou.hda.loadedFiles():              # Skip the hda file containing the definition that was passed in.         if hda_file == definition.libraryFilePath():             continue         for other_definition in hou.hda.definitionsInFile(hda_file):             # print(other_definition)             if node_version in other_definition.nodeTypeName().split(&#8216;::&#8217;)[0]:                 result.append(other_definition)             else:                 pass     return result      def getHighestVersion(node):     node_path = node.path()     otherDef = otherDefinitions(node_path)     highest_version_def = sorted(otherDef, key=lambda x: x.nodeTypeName().split(&#8220;::&#8221;)[1])[-1]     highest_version_name = highest_version_def.nodeTypeName()     node.changeNodeType(highest_version_def.nodeTypeName(), keep_parms=True)     print(f&#8221;Updated HDA {node_path} to version {highest_version_name}&#8221;)                     nodeM = hou.node(&#8216;\/path\/to\/your_node&#8217;) # replace path with actual node path node_path = nodeM.path() # get the node path since after we replace the type the direct reference will no longer exist<br \/>\ngetHighestVersion(nodeM) # update the HDAs version type<br \/>\nlock_hda(node_path) # lock and unlock the HDA to match internal contents &#8220;`<\/p>\n<p class=\"\">justt got this guy done thought id share since i had to do some digging on how to do it! takes an input node and gets the highest version of that HDA and then updates it to that version and locks and unlocks the HDA to match contents!<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`import hou def lock_hda(node_path): &#8220;&#8221;&#8221; Lock the HDA at the given node path. And then Unlock it now that it has been matched &#8220;&#8221;&#8221; # Get the node node = hou.node(node_path) # Check if node exists if node is None: print(&#8220;Node does not exist.&#8221;) return # Lock the HDA node.matchCurrentDefinition() # Unlock the HDA node.allowEditingOfContents() &hellip; <a href=\"http:\/\/fx-td.com\/houdiniandchill\/2023\/09\/19\/archived-post-by-colemapt96\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Archived post by Colemapt96<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/posts\/704"}],"collection":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/comments?post=704"}],"version-history":[{"count":0,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/posts\/704\/revisions"}],"wp:attachment":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/media?parent=704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/categories?post=704"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/tags?post=704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}