mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
Added set_id and remove_id
This commit is contained in:
parent
d5cdf22156
commit
a73f529d03
1 changed files with 26 additions and 0 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
import re
|
||||
import os
|
||||
import uuid
|
||||
|
||||
import bson
|
||||
import json
|
||||
import logging
|
||||
|
|
@ -677,6 +679,30 @@ def get_id(node):
|
|||
return cmds.getAttr("{}.cbId".format(node))
|
||||
|
||||
|
||||
def set_id(asset_id, node):
|
||||
"""Add cbId to `node` unless one already exists.
|
||||
|
||||
Args:
|
||||
asset_id (str): the unique asset code from the database
|
||||
node (str): the node to add the "cbId" on
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
|
||||
attr = "{0}.cbId".format(node)
|
||||
if not cmds.attributeQuery("cbId", node=node, exists=True):
|
||||
cmds.addAttr(node, longName="cbId", dataType="string")
|
||||
_, uid = str(uuid.uuid4()).rsplit("-", 1)
|
||||
cb_uid = "{}:{}".format(asset_id, uid)
|
||||
cmds.setAttr(attr, cb_uid, type="string")
|
||||
|
||||
|
||||
def remove_id(node):
|
||||
if cmds.attributeQuery("cbId", node=node, exists=True):
|
||||
cmds.deleteAttr("{}.cbId".format(node))
|
||||
|
||||
|
||||
def get_representation_file(representation, template=TEMPLATE):
|
||||
"""
|
||||
Rebuild the filepath of the representation's context
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue