create workfile instance by default

This commit is contained in:
iLLiCiTiT 2021-05-27 14:54:00 +02:00
parent fafc840fd1
commit 801444ef9c

View file

@ -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)
))