Skip to content

Commit

Permalink
Create collect_udim.py
Browse files Browse the repository at this point in the history
publish UDIM tiles in Publisher
  • Loading branch information
antirotor authored Oct 22, 2024
1 parent d80ae9f commit be50dd7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions client/ayon_core/plugins/publish/collect_udim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Publish UDIM tiles."""
import re

import pyblish.api
from ayon_core.lib import BoolDef
from ayon_core.pipeline import publish

UDIM_REGEX = re.compile(r"(.*)\.(?P<udim>\d{4})\.(.*)")


class CollectUDIMs(
pyblish.api.InstancePlugin, publish.AYONPyblishPluginMixin):
"""Collect UDIMs tiles."""

label = "Collect UDIMs"
order = pyblish.api.CollectorOrder + 0.499
families = ["image"]

def process(self, instance):
# type: (pyblish.api.Instance) -> None
instance_settings = self.get_attr_values_from_data(instance.data)
is_udim = instance_settings.get("isUDIM", False)
if not is_udim:
return

for representation in instance.data["representations"]:
if isinstance(representation["files"], (list, tuple)):
continue

# sourcery skip: use-named-expression
match = re.search(UDIM_REGEX, representation["files"])
if match:
representation["udim"] = [match.group("udim")]

@classmethod
def get_attribute_defs(cls):
return [
BoolDef("isUDIM",
label="Is UDIM",
default=False)
]

0 comments on commit be50dd7

Please sign in to comment.