Collect instances for publishing.
CollectInstances
Bases: InstancePlugin
Collect instances for publishing.
Source code in client/ayon_mocha/plugins/publish/collect_instances.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 | class CollectInstances(pyblish.api.InstancePlugin):
"""Collect instances for publishing."""
label = "Collect Instances"
order = pyblish.api.CollectorOrder - 0.4
hosts: ClassVar[list[str]] = ["mochapro"]
log: Logger
def process(self, instance: pyblish.api.Instance) -> None:
"""Process the plugin."""
self.log.debug("Collecting data for %s", instance)
# Define nice instance label
instance_node = instance.data.get(
"transientData", {}).get("instance_node")
name = instance_node.label if instance_node else instance.name
label = f"{name} ({instance.data['folderPath']})"
# Set frame start handle and frame end handle if frame ranges are
# available
if "frameStart" in instance.data and "frameEnd" in instance.data:
# Enforce existence if handles
instance.data.setdefault("handleStart", 0)
instance.data.setdefault("handleEnd", 0)
# Compute frame start handle and end start handle
frame_start_handle = (
instance.data["frameStart"] - instance.data["handleStart"]
)
frame_end_handle = (
instance.data["frameEnd"] - instance.data["handleEnd"]
)
instance.data["frameStartHandle"] = frame_start_handle
instance.data["frameEndHandle"] = frame_end_handle
# Include frame range in label
label += f" [{int(frame_start_handle)}-{int(frame_end_handle)}]"
instance.data["label"] = label
|
process(instance)
Process the plugin.
Source code in client/ayon_mocha/plugins/publish/collect_instances.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 | def process(self, instance: pyblish.api.Instance) -> None:
"""Process the plugin."""
self.log.debug("Collecting data for %s", instance)
# Define nice instance label
instance_node = instance.data.get(
"transientData", {}).get("instance_node")
name = instance_node.label if instance_node else instance.name
label = f"{name} ({instance.data['folderPath']})"
# Set frame start handle and frame end handle if frame ranges are
# available
if "frameStart" in instance.data and "frameEnd" in instance.data:
# Enforce existence if handles
instance.data.setdefault("handleStart", 0)
instance.data.setdefault("handleEnd", 0)
# Compute frame start handle and end start handle
frame_start_handle = (
instance.data["frameStart"] - instance.data["handleStart"]
)
frame_end_handle = (
instance.data["frameEnd"] - instance.data["handleEnd"]
)
instance.data["frameStartHandle"] = frame_start_handle
instance.data["frameEndHandle"] = frame_end_handle
# Include frame range in label
label += f" [{int(frame_start_handle)}-{int(frame_end_handle)}]"
instance.data["label"] = label
|