mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Implement plug-ins to support workfile publishing
This commit is contained in:
parent
ec2f10caf3
commit
c3fca896d4
4 changed files with 89 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
import pyblish.api
|
||||
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
|
||||
class CollectCurrentFile(pyblish.api.ContextPlugin):
|
||||
"""Inject the current working file into context"""
|
||||
|
||||
order = pyblish.api.CollectorOrder - 0.49
|
||||
label = "Current Workfile"
|
||||
hosts = ["substancepainter"]
|
||||
|
||||
def process(self, context):
|
||||
host = registered_host()
|
||||
path = host.get_current_workfile()
|
||||
context.data["currentFile"] = path
|
||||
self.log.debug(f"Current workfile: {path}")
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
import os
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class CollectWorkfileRepresentation(pyblish.api.InstancePlugin):
|
||||
"""Create a publish representation for the current workfile instance."""
|
||||
|
||||
order = pyblish.api.CollectorOrder
|
||||
label = "Workfile representation"
|
||||
hosts = ['substancepainter']
|
||||
families = ["workfile"]
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
context = instance.context
|
||||
current_file = context.data["currentFile"]
|
||||
|
||||
folder, file = os.path.split(current_file)
|
||||
filename, ext = os.path.splitext(file)
|
||||
|
||||
instance.data['representations'] = [{
|
||||
'name': ext.lstrip("."),
|
||||
'ext': ext.lstrip("."),
|
||||
'files': file,
|
||||
"stagingDir": folder,
|
||||
}]
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import pyblish.api
|
||||
|
||||
from openpype.lib import version_up
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
|
||||
class IncrementWorkfileVersion(pyblish.api.ContextPlugin):
|
||||
"""Increment current workfile version."""
|
||||
|
||||
order = pyblish.api.IntegratorOrder + 1
|
||||
label = "Increment Workfile Version"
|
||||
optional = True
|
||||
hosts = ["substancepainter"]
|
||||
|
||||
def process(self, context):
|
||||
|
||||
assert all(result["success"] for result in context.data["results"]), (
|
||||
"Publishing not successful so version is not increased.")
|
||||
|
||||
host = registered_host()
|
||||
path = context.data["currentFile"]
|
||||
self.log.info(f"Incrementing current workfile to: {path}")
|
||||
host.save_workfile(version_up(path))
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import pyblish.api
|
||||
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
|
||||
class SaveCurrentWorkfile(pyblish.api.ContextPlugin):
|
||||
"""Save current workfile"""
|
||||
|
||||
label = "Save current workfile"
|
||||
order = pyblish.api.ExtractorOrder - 0.49
|
||||
hosts = ["substancepainter"]
|
||||
|
||||
def process(self, context):
|
||||
|
||||
host = registered_host()
|
||||
assert context.data['currentFile'] == host.get_current_workfile()
|
||||
|
||||
if host.has_unsaved_changes():
|
||||
self.log.info("Saving current file..")
|
||||
host.save_workfile()
|
||||
else:
|
||||
self.log.debug("Skipping workfile save because there are no "
|
||||
"unsaved changes.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue