Skip to content

create_textures

Creator plugin for creating textures.

CreateTextures

Bases: TextureCreator

Create a texture set.

Source code in client/ayon_substancedesigner/plugins/create/create_textures.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class CreateTextures(TextureCreator):
    """Create a texture set."""
    identifier = "io.ayon.creators.substancedesigner.textureset"
    label = "Textures"
    product_base_type = "textureSet"
    product_type = product_base_type
    icon = "picture-o"

    default_variant = "Main"
    review = False
    exportFileFormat = "png"

    def create(self, product_name, instance_data, pre_create_data):
        current_graph_name = get_current_graph_name()
        if not current_graph_name:
            raise CreatorError("Can't create a Texture Set instance without "
                               "the Substance Designer Graph.")
        # Transfer settings from pre create to instance
        creator_attributes = instance_data.setdefault(
            "creator_attributes", dict())
        for key in [
            "review",
            "exportFileFormat",
            "exportedGraphs",
            "exportedGraphsOutputs"
        ]:
            if key in pre_create_data:
                creator_attributes[key] = pre_create_data[key]

        instance = self.create_instance_in_context(product_name,
                                                   instance_data)
        set_instance(
            instance_id=instance["instance_id"],
            instance_data=instance.data_to_store()
        )

    def get_instance_attr_defs(self):
        return [
            BoolDef("review",
                    label="Review",
                    tooltip="Mark as reviewable",
                    default=self.review),
            EnumDef("exportFileFormat",
                    items={
                        # TODO: Get available extensions from substance API
                        "bmp": "bmp",
                        "dds": "dds",
                        "jpeg": "jpeg",
                        "jpg": "jpg",
                        "png": "png",
                        "tga": "targa",
                        "tif": "tiff",
                        "surface": "surface",
                        "hdr": "hdr",
                        "exr": "exr",
                        "jif": "jif",
                        "jpe": "jpe",
                        "webp": "webp",
                        # TODO: File formats that combine the exported textures
                        #   like psd are not correctly supported due to
                        #   publishing only a single file
                        # "sbsar": "sbsar",
                    },
                    default=self.exportFileFormat,
                    label="File type"),
            EnumDef("exportedGraphs",
                    items=get_sd_graphs_by_package(),
                    multiselection=True,
                    default=None,
                    label="Graphs To be Exported"),
            EnumDef("exportedGraphsOutputs",
                    items=get_output_maps_from_graphs(),
                    multiselection=True,
                    default=None,
                    label="Graph Outputs To be Exported")
        ]