Skip to content

collect_workfile

Collect current work file.

CollectWorkfile

Bases: InstancePlugin

Inject the current working file into context.

Source code in client/ayon_marvelousdesigner/plugins/publish/collect_workfile.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
47
48
49
50
51
class CollectWorkfile(pyblish.api.InstancePlugin):
    """Inject the current working file into context."""

    order = pyblish.api.CollectorOrder - 0.01
    label = "Collect Workfile"
    hosts: ClassVar[list[str]] = ["marvelousdesigner"]
    families: ClassVar[list[str]] = ["workfile"]

    def process(self, instance: pyblish.api.Instance) -> None:
        """Inject the current working file.

        Args:
            instance (pyblish.api.Instance): The instance to process.
        """
        context = instance.context
        current_file = context.data.get("currentFile")
        filepath = Path(current_file)
        ayon_temp_dir = os.getenv("AYON_TEMP_DIR", "")
        if ayon_temp_dir and filepath.parent == ayon_temp_dir:
            self.log.warning("Deactivating workfile instance because no "
                             "current filepath is found. Please save your "
                             "workfile.")
            instance.data["publish"] = False
            return

        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)

Inject the current working file.

Parameters:

Name Type Description Default
instance Instance

The instance to process.

required
Source code in client/ayon_marvelousdesigner/plugins/publish/collect_workfile.py
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
def process(self, instance: pyblish.api.Instance) -> None:
    """Inject the current working file.

    Args:
        instance (pyblish.api.Instance): The instance to process.
    """
    context = instance.context
    current_file = context.data.get("currentFile")
    filepath = Path(current_file)
    ayon_temp_dir = os.getenv("AYON_TEMP_DIR", "")
    if ayon_temp_dir and filepath.parent == ayon_temp_dir:
        self.log.warning("Deactivating workfile instance because no "
                         "current filepath is found. Please save your "
                         "workfile.")
        instance.data["publish"] = False
        return

    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,
                }
            ],
        }
    )