Bases: MayaInstancePlugin
, OptionalPyblishPluginMixin
Validates Maya Workpace "images" file rule matches project settings.
This validates against the configured default render image folder
Studio Settings > Project > Maya > Render Settings > Default render image folder.
Source code in client/ayon_maya/plugins/publish/validate_render_image_rule.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 | class ValidateRenderImageRule(plugin.MayaInstancePlugin,
OptionalPyblishPluginMixin):
"""Validates Maya Workpace "images" file rule matches project settings.
This validates against the configured default render image folder:
Studio Settings > Project > Maya >
Render Settings > Default render image folder.
"""
order = ValidateContentsOrder
label = "Images File Rule (Workspace)"
families = ["renderlayer"]
actions = [RepairAction]
optional = False
def process(self, instance):
if not self.is_active(instance.data):
return
required_images_rule = os.path.normpath(
self.get_default_render_image_folder(instance)
)
current_images_rule = os.path.normpath(
cmds.workspace(fileRuleEntry="images")
)
if current_images_rule != required_images_rule:
raise PublishValidationError(
(
"Invalid workspace `images` file rule value: '{}'. "
"Must be set to: '{}'"
).format(current_images_rule, required_images_rule))
@classmethod
def repair(cls, instance):
required_images_rule = cls.get_default_render_image_folder(instance)
current_images_rule = cmds.workspace(fileRuleEntry="images")
if current_images_rule != required_images_rule:
cmds.workspace(fileRule=("images", required_images_rule))
cmds.workspace(saveWorkspace=True)
@classmethod
def get_default_render_image_folder(cls, instance):
# Allow custom staging dir to override the expected output directory
# of the renders
if instance.data.get("stagingDir_is_custom", False):
staging_dir = instance.data.get("stagingDir")
if staging_dir:
cls.log.debug(
"Staging dir found: \"{}\". Ignoring setting from "
"`project_settings/maya/render_settings/"
"default_render_image_folder`.".format(staging_dir)
)
return staging_dir
return (
instance.context.data
["project_settings"]
["maya"]
["render_settings"]
["default_render_image_folder"]
)
|