{"id":235,"date":"2018-08-17T12:12:19","date_gmt":"2018-08-17T19:12:19","guid":{"rendered":"http:\/\/fx-td.com\/houdiniandchill\/?p=235"},"modified":"2018-08-17T12:12:33","modified_gmt":"2018-08-17T19:12:33","slug":"archived-post-by-baldrax","status":"publish","type":"post","link":"http:\/\/fx-td.com\/houdiniandchill\/2018\/08\/17\/archived-post-by-baldrax\/","title":{"rendered":"Archived post by Baldrax"},"content":{"rendered":"<p class=\"\">&#8220;`python class InLockedAsset():     &#8221;&#8217;Class for unlocking and relocking nested nodes.&#8221;&#8217;          def __init__(self, node=None, verbose=False):         self.baseNode = node         self.verbose = verbose         print &#8216;BASENODE:&#8217;,node.path(), self.baseNode.path()         self.isInLockedAsset = self.baseNode.isInsideLockedHDA()         self.__buildLockedNodeList__()          def __buildLockedNodeList__(self):         self.__lockedNodeList__ = []         inLockedAsset = self.isInLockedAsset         currentNode = self.baseNode         while inLockedAsset:             currentNode = currentNode.parent()             if isHDA(currentNode):                 self.__lockedNodeList__.append(currentNode)             inLockedAsset = currentNode.isInsideLockedHDA()                      self.__lockedNodeList__.reverse()                  def firstUnlockedParent(self):         if len(self.__lockedNodeList__) > 0:             return self.__lockedNodeList__[0]         else:             return None                  def unlockParentNodes(self):         for currentNode in self.__lockedNodeList__:             print &#8216;Unlocking asset: %s&#8217; % currentNode.path()             currentNode.allowEditingOfContents()             def relockParents(self):         topParent = self.firstUnlockedParent()         if topParent is not None:             try:                 print &#8216;Re-locking asset: %s&#8217; % topParent.path()                 topParent.matchCurrentDefinition()             except hou.OperationFailed:                 if topParent.isLocked():                     pass                 else:                     topParent.matchCurrentDefinition() &#8220;` Usage: &#8220;`python inAssetNode = InLockedAsset(node=&#8217;\/path\/to\/node&#8217;) inAssetNode.unlockParentNodes() &#8220;` Then, if you want to re-lock them: &#8220;`python inAssetNode.relockParents() &#8220;` Feel free to clean this up.  Some funky stuff in there.<\/p>\n<p class=\"\">Needs this too: &#8220;`python def isHDA(node):     try:         node.type().definition().libraryFilePath()         return True     except:         return False &#8220;`<\/p>\n<p class=\"\">Old eyes<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`python class InLockedAsset(): &#8221;&#8217;Class for unlocking and relocking nested nodes.&#8221;&#8217; def __init__(self, node=None, verbose=False): self.baseNode = node self.verbose = verbose print &#8216;BASENODE:&#8217;,node.path(), self.baseNode.path() self.isInLockedAsset = self.baseNode.isInsideLockedHDA() self.__buildLockedNodeList__() def __buildLockedNodeList__(self): self.__lockedNodeList__ = [] inLockedAsset = self.isInLockedAsset currentNode = self.baseNode while inLockedAsset: currentNode = currentNode.parent() if isHDA(currentNode): self.__lockedNodeList__.append(currentNode) inLockedAsset = currentNode.isInsideLockedHDA() self.__lockedNodeList__.reverse() def firstUnlockedParent(self): if len(self.__lockedNodeList__) > &hellip; <a href=\"http:\/\/fx-td.com\/houdiniandchill\/2018\/08\/17\/archived-post-by-baldrax\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Archived post by Baldrax<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/posts\/235"}],"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=235"}],"version-history":[{"count":0,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/posts\/235\/revisions"}],"wp:attachment":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}