diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py index 21c0a78427..d6714a8277 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py @@ -1,3 +1,4 @@ +import os import json import copy import pyblish.api @@ -230,3 +231,40 @@ class CollectInstances(pyblish.api.ContextPlugin): instance_data["layers"] = render_pass_layers return context.create_instance(**instance_data) + + def add_workfile_instance(self, context): + current_file = context.data["currentFile"] + + self.log.info( + "Workfile path used for workfile family: {}".format(current_file) + ) + + dirpath, filename = os.path.split(current_file) + basename, ext = os.path.splitext(filename) + instance = context.create_instance(name=basename) + + task_name = io.Session["AVALON_TASK"] + subset_name = "workfile" + task_name.capitalize() + + # Create Workfile instance + instance.data.update({ + "subset": subset_name, + "asset": context.data["asset"], + "label": subset_name, + "publish": True, + "family": "workfile", + "families": ["workfile"], + "frameStart": context.data["frameStart"], + "frameEnd": context.data["frameEnd"], + "handleStart": context.data["handleStart"], + "handleEnd": context.data["handleEnd"], + "representations": [{ + "name": ext.lstrip("."), + "ext": ext.lstrip("."), + "files": filename, + "stagingDir": dirpath + }] + }) + self.log.info("Collected workfile instance: {}".format( + json.dumps(instance.data, indent=4) + ))