Archived post by Baldrax

“`python class InLockedAsset(): ”’Class for unlocking and relocking nested nodes.”’ def __init__(self, node=None, verbose=False): self.baseNode = node self.verbose = verbose print ‘BASENODE:’,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 ‘Unlocking asset: %s’ % currentNode.path() currentNode.allowEditingOfContents() def relockParents(self): topParent = self.firstUnlockedParent() if topParent is not None: try: print ‘Re-locking asset: %s’ % topParent.path() topParent.matchCurrentDefinition() except hou.OperationFailed: if topParent.isLocked(): pass else: topParent.matchCurrentDefinition() “` Usage: “`python inAssetNode = InLockedAsset(node=’/path/to/node’) inAssetNode.unlockParentNodes() “` Then, if you want to re-lock them: “`python inAssetNode.relockParents() “` Feel free to clean this up. Some funky stuff in there.

Needs this too: “`python def isHDA(node): try: node.type().definition().libraryFilePath() return True except: return False “`

Old eyes