Skip to content

extract_renderpreset

ExtractRenderPreset

Bases: Extractor

Extract Render Preset

Source code in client/ayon_max/plugins/publish/extract_renderpreset.py
 7
 8
 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
class ExtractRenderPreset(publish.Extractor):
    """Extract Render Preset"""

    order = pyblish.api.ExtractorOrder - 0.3
    label = "Extract Render Preset"
    hosts = ["max"]
    families = ["renderpreset"]

    def process(self, instance):
        staging_dir = self.staging_dir(instance)
        filename = f"{instance.name}.rps"
        filepath = os.path.join(staging_dir, filename)
        self.log.debug("Writing Render Preset to '{}'".format(filepath))

        # export render preset for production
        # TODO: we can support to save which presets
        # and which categories later.
        rt.renderpresets.SaveAll(0, filepath)

        representation = {
            "name": "rps",
            "ext": "rps",
            "files": filename,
            "stagingDir": staging_dir,
        }

        if "representations" not in instance.data:
            instance.data["representations"] = []

        instance.data["representations"].append(representation)
        self.log.debug(
            "Extracted instance '%s' to: %s" % (instance.name, filepath)
        )