Bases: MayaInstancePlugin
, OptionalPyblishPluginMixin
Validate renderable camera count for layer and token.
Pipeline is supporting multiple renderable cameras per layer, but image prefix must contain token.
Source code in client/ayon_maya/plugins/publish/validate_render_single_camera.py
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
77
78
79
80
81
82 | class ValidateRenderSingleCamera(plugin.MayaInstancePlugin,
OptionalPyblishPluginMixin):
"""Validate renderable camera count for layer and <Camera> token.
Pipeline is supporting multiple renderable cameras per layer, but image
prefix must contain <Camera> token.
"""
order = ValidateContentsOrder
label = "Render Single Camera"
families = ["renderlayer",
"vrayscene"]
actions = [ayon_maya.api.action.SelectInvalidAction]
optional = False
R_CAMERA_TOKEN = re.compile(r'%c|<camera>', re.IGNORECASE)
def process(self, instance):
"""Process all the cameras in the instance"""
if not self.is_active(instance.data):
return
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError(
"Invalid render cameras.",
description=self.get_description()
)
@classmethod
def get_invalid(cls, instance):
cameras = instance.data.get("cameras", [])
renderer = cmds.getAttr('defaultRenderGlobals.currentRenderer').lower()
# handle various renderman names
if renderer.startswith('renderman'):
renderer = 'renderman'
file_prefix = cmds.getAttr(
RenderSettings.get_image_prefix_attr(renderer)
)
renderlayer = instance.data["renderlayer"]
if len(cameras) > 1:
if re.search(cls.R_CAMERA_TOKEN, file_prefix):
# if there is <Camera> token in prefix and we have more then
# 1 camera, all is ok.
return
cls.log.error(
"Multiple renderable cameras found for %s: %s ",
renderlayer, ", ".join(cameras))
return [renderlayer] + cameras
elif len(cameras) < 1:
cls.log.error("No renderable cameras found for %s ", renderlayer)
return [renderlayer]
def get_description(self):
return inspect.cleandoc(
"""### Render Cameras Invalid
Your render cameras are misconfigured. You may have no render
camera set or have multiple cameras with a render filename
prefix that does not include the `<Camera>` token.
See the logs for more details about the cameras.
"""
)
|
process(instance)
Process all the cameras in the instance
Source code in client/ayon_maya/plugins/publish/validate_render_single_camera.py
32
33
34
35
36
37
38
39
40
41 | def process(self, instance):
"""Process all the cameras in the instance"""
if not self.is_active(instance.data):
return
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError(
"Invalid render cameras.",
description=self.get_description()
)
|