Skip to content

validate_no_default_camera

ValidateNoDefaultCameras

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Ensure no default (startup) cameras are in the instance.

This might be unnecessary. In the past there were some issues with referencing/importing files that contained the start up cameras overriding settings when being loaded and sometimes being skipped.

Source code in client/ayon_maya/plugins/publish/validate_no_default_camera.py
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
class ValidateNoDefaultCameras(plugin.MayaInstancePlugin,
                               OptionalPyblishPluginMixin):
    """Ensure no default (startup) cameras are in the instance.

    This might be unnecessary. In the past there were some issues with
    referencing/importing files that contained the start up cameras overriding
    settings when being loaded and sometimes being skipped.
    """

    order = ValidateContentsOrder
    families = ['camera']
    label = "No Default Cameras"
    actions = [ayon_maya.api.action.SelectInvalidAction]
    optional = False

    @staticmethod
    def get_invalid(instance):
        cameras = cmds.ls(instance, type='camera', long=True)
        return [cam for cam in cameras if
                cmds.camera(cam, query=True, startupCamera=True)]

    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(
                "Default cameras found:\n\n{0}".format(
                    _as_report_list(sorted(invalid))
                ),
                title="Default cameras"
            )

process(instance)

Process all the cameras in the instance

Source code in client/ayon_maya/plugins/publish/validate_no_default_camera.py
39
40
41
42
43
44
45
46
47
48
49
50
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(
            "Default cameras found:\n\n{0}".format(
                _as_report_list(sorted(invalid))
            ),
            title="Default cameras"
        )