Skip to content

collect_workfile_representation

CollectWorkfileRepresentation

Bases: InstancePlugin

Create a publish representation for the current workfile instance.

Source code in client/ayon_substancedesigner/plugins/publish/collect_workfile_representation.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class CollectWorkfileRepresentation(pyblish.api.InstancePlugin):
    """Create a publish representation for the current workfile instance."""

    order = pyblish.api.CollectorOrder
    label = "Workfile representation"
    hosts = ["substancedesigner"]
    families = ["workfile"]

    def process(self, instance):

        context = instance.context
        current_file = context.data.get("currentFile")
        if not current_file:
            self.log.error("Current file is not saved. File could not be "
                           "collected as workfile representation.")
            return

        folder, file = os.path.split(current_file)
        filename, ext = os.path.splitext(file)

        instance.data["representations"] = [{
            "name": ext.lstrip("."),
            "ext": ext.lstrip("."),
            "files": file,
            "stagingDir": folder,
        }]