Skip to content

extract_matlib

ExtractMatlib

Bases: Extractor

Extract Material Library

Source code in client/ayon_max/plugins/publish/extract_matlib.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
40
41
42
class ExtractMatlib(publish.Extractor):
    """
    Extract Material Library
    """

    order = pyblish.api.ExtractorOrder - 0.2
    label = "Extract Material Library"
    hosts = ["max"]
    families = ["matlib"]

    settings_category = "max"

    def process(self, instance):
        self.log.debug("Extracting Material Library.")

        stagingdir = self.staging_dir(instance)
        filename = "{name}.mat".format(**instance.data)
        filepath = os.path.join(stagingdir, filename)
        matlib_filepath = instance.data["matlib_filepath"]
        rt.sme.SaveMtlLibAs(matlib_filepath, newPath=filepath)

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

        self.log.info("Performing Extraction ...")

        representation = {
            "name": "mat",
            "ext": "mat",
            "files": filename,
            "stagingDir": stagingdir,
        }
        instance.data["representations"].append(representation)
        self.log.info(
            "Extracted instance '%s' to: %s" % (instance.name, filepath)
        )