Skip to content

extract_sbsar

ExtractSbsar

Bases: Extractor

Extract SBSAR

Source code in client/ayon_substancedesigner/plugins/publish/extract_sbsar.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
class ExtractSbsar(publish.Extractor):
    """Extract SBSAR

    """

    label = "Extract SBSAR"
    hosts = ["substancedesigner"]
    families = ["sbsar"]

    order = publish.Extractor.order

    def process(self, instance):
        ctx = sd.getContext()
        exporterInstance = SDSBSARExporter(ctx, None)
        exporter = exporterInstance.sNew()

        graph_name = instance.data["graph_name"]
        sd_graph = get_sd_graph_by_name(graph_name)

        current_file = instance.context.data["currentFile"]
        filename = os.path.basename(current_file)
        filename = filename.replace("sbs", "sbsar")
        staging_dir = self.staging_dir(instance)
        filepath = os.path.normpath(
            os.path.join(staging_dir, filename))
        # export the graph with filepath
        exporter.exportPackageToSBSAR(sd_graph.getPackage(), filepath)

        if "representations" not in instance.data:
            instance.data["representations"] = []
        representation = {
            'name': 'sbsar',
            'ext': 'sbsar',
            'files': filename,
            "stagingDir": staging_dir,
        }

        instance.data["representations"].append(representation)