Skip to content

Commit e9db845

Browse files
authored
Merge pull request #346 from ynput/enhancement/l1446-version-pinning
Load: Added actions to lock and unlock container versions
2 parents c7387f4 + f66aba9 commit e9db845

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
5+
from maya import cmds
6+
7+
from ayon_core.pipeline import InventoryAction
8+
9+
10+
class LockVersions(InventoryAction):
11+
label = "Lock versions"
12+
icon = "lock"
13+
color = "#ffffff"
14+
order = -1
15+
16+
@staticmethod
17+
def is_compatible(container: dict[str, Any]) -> bool:
18+
return container.get("version_locked") is not True
19+
20+
def process(self, containers: list[dict[str, Any]]) -> bool:
21+
for container in containers:
22+
if container.get("version_locked") is True:
23+
continue
24+
node = container["objectName"]
25+
key = "version_locked"
26+
if cmds.attributeQuery(key, node=node, exists=True):
27+
cmds.deleteAttr(f"{node}.{key}")
28+
cmds.addAttr(node, longName=key, attributeType=bool)
29+
cmds.setAttr(
30+
f"{node}.{key}", True, keyable=False, channelBox=True
31+
)
32+
return True
33+
34+
35+
class UnlockVersions(InventoryAction):
36+
label = "Unlock versions"
37+
icon = "lock-open"
38+
color = "#ffffff"
39+
order = -1
40+
41+
@staticmethod
42+
def is_compatible(container: dict[str, Any]) -> bool:
43+
return container.get("version_locked") is True
44+
45+
def process(self, containers: list[dict[str, Any]]) -> bool:
46+
for container in containers:
47+
if container.get("version_locked") is not True:
48+
continue
49+
node = container["objectName"]
50+
key = "version_locked"
51+
if cmds.attributeQuery(key, node=node, exists=True):
52+
cmds.deleteAttr(f"{node}.{key}")
53+
return True

0 commit comments

Comments
 (0)