Skip to content

collect_workfile

Collect current work file.

CollectWorkfile

Bases: InstancePlugin

Inject the current working file into context

Source code in client/ayon_max/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
class CollectWorkfile(pyblish.api.InstancePlugin):
    """Inject the current working file into context"""

    order = pyblish.api.CollectorOrder - 0.01
    label = "Collect 3dsmax Workfile"
    hosts = ['max']
    families = ["workfile"]

    def process(self, instance):
        """Inject the current working file."""
        context = instance.context
        folder = rt.maxFilePath
        file = rt.maxFileName
        if not folder or not file:
            self.log.error("Scene is not saved.")
        ext = os.path.splitext(file)[-1].lstrip(".")

        data = {}

        data.update({
            "setMembers": context.data["currentFile"],
            "frameStart": context.data["frameStart"],
            "frameEnd": context.data["frameEnd"],
            "handleStart": context.data["handleStart"],
            "handleEnd": context.data["handleEnd"]
        })

        data["representations"] = [{
            "name": ext,
            "ext": ext,
            "files": file,
            "stagingDir": folder,
        }]

        instance.data.update(data)
        self.log.debug("Collected data: {}".format(data))
        self.log.debug("Collected instance: {}".format(file))
        self.log.debug("staging Dir: {}".format(folder))

process(instance)

Inject the current working file.

Source code in client/ayon_max/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
def process(self, instance):
    """Inject the current working file."""
    context = instance.context
    folder = rt.maxFilePath
    file = rt.maxFileName
    if not folder or not file:
        self.log.error("Scene is not saved.")
    ext = os.path.splitext(file)[-1].lstrip(".")

    data = {}

    data.update({
        "setMembers": context.data["currentFile"],
        "frameStart": context.data["frameStart"],
        "frameEnd": context.data["frameEnd"],
        "handleStart": context.data["handleStart"],
        "handleEnd": context.data["handleEnd"]
    })

    data["representations"] = [{
        "name": ext,
        "ext": ext,
        "files": file,
        "stagingDir": folder,
    }]

    instance.data.update(data)
    self.log.debug("Collected data: {}".format(data))
    self.log.debug("Collected instance: {}".format(file))
    self.log.debug("staging Dir: {}".format(folder))