Skip to content

collect_workfile

CollectWorkfile

Bases: BlenderInstancePlugin

Inject workfile data into its instance.

Source code in client/ayon_blender/plugins/publish/collect_workfile.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
43
44
45
46
class CollectWorkfile(plugin.BlenderInstancePlugin):
    """Inject workfile data into its instance."""

    order = CollectorOrder
    label = "Collect Workfile"
    hosts = ["blender"]
    families = ["workfile"]

    def process(self, instance):
        """Process collector."""

        context = instance.context
        filepath = context.data.get("currentFile")
        if not filepath:
            self.log.warning("Deactivating workfile instance because no "
                             "current filepath is found. Please save your "
                             "workfile.")
            instance.data["publish"] = False
            return

        filepath = Path(filepath)
        ext = filepath.suffix

        instance.data.update(
            {
                "setMembers": [filepath.as_posix()],
                "frameStart": context.data.get("frameStart", 1),
                "frameEnd": context.data.get("frameEnd", 1),
                "handleStart": context.data.get("handleStart", 1),
                "handledEnd": context.data.get("handleEnd", 1),
                "representations": [
                    {
                        "name": ext.lstrip("."),
                        "ext": ext.lstrip("."),
                        "files": filepath.name,
                        "stagingDir": filepath.parent,
                    }
                ],
            }
        )

process(instance)

Process collector.

Source code in client/ayon_blender/plugins/publish/collect_workfile.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
def process(self, instance):
    """Process collector."""

    context = instance.context
    filepath = context.data.get("currentFile")
    if not filepath:
        self.log.warning("Deactivating workfile instance because no "
                         "current filepath is found. Please save your "
                         "workfile.")
        instance.data["publish"] = False
        return

    filepath = Path(filepath)
    ext = filepath.suffix

    instance.data.update(
        {
            "setMembers": [filepath.as_posix()],
            "frameStart": context.data.get("frameStart", 1),
            "frameEnd": context.data.get("frameEnd", 1),
            "handleStart": context.data.get("handleStart", 1),
            "handledEnd": context.data.get("handleEnd", 1),
            "representations": [
                {
                    "name": ext.lstrip("."),
                    "ext": ext.lstrip("."),
                    "files": filepath.name,
                    "stagingDir": filepath.parent,
                }
            ],
        }
    )