Skip to content

validate_renderer_redshift_proxy

ValidateRendererRedshiftProxy

Bases: InstancePlugin

Validates Redshift as the current renderer for creating Redshift Proxy

Source code in client/ayon_max/plugins/publish/validate_renderer_redshift_proxy.py
 9
10
11
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
50
51
52
53
54
class ValidateRendererRedshiftProxy(pyblish.api.InstancePlugin):
    """
    Validates Redshift as the current renderer for creating
    Redshift Proxy
    """

    order = pyblish.api.ValidatorOrder
    families = ["redshiftproxy"]
    hosts = ["max"]
    label = "Redshift Renderer"
    actions = [RepairAction]

    def process(self, instance):
        invalid = self.get_redshift_renderer(instance)
        if invalid:
            raise PublishValidationError("Please install Redshift for 3dsMax"
                                         " before using the Redshift proxy instance")   # noqa
        invalid = self.get_current_renderer(instance)
        if invalid:
            raise PublishValidationError("The Redshift proxy extraction"
                                         "discontinued since the current renderer is not Redshift")  # noqa

    def get_redshift_renderer(self, instance):
        invalid = list()
        max_renderers_list = str(rt.RendererClass.classes)
        if "Redshift_Renderer" not in max_renderers_list:
            invalid.append(max_renderers_list)

        return invalid

    def get_current_renderer(self, instance):
        invalid = list()
        renderer_class = get_current_renderer()
        current_renderer = str(renderer_class).split(":")[0]
        if current_renderer != "Redshift_Renderer":
            invalid.append(current_renderer)

        return invalid

    @classmethod
    def repair(cls, instance):
        for Renderer in rt.RendererClass.classes:
            renderer = Renderer()
            if "Redshift_Renderer" in str(renderer):
                rt.renderers.production = renderer
                break