class IncrementWorkfileVersion(pyblish.api.ContextPlugin):
"""Save current file"""
label = "Save current file"
order = pyblish.api.ExtractorOrder - 0.49
hosts = ["zbrush"]
families = ["workfile"]
def process(self, context):
host: IWorkfileHost = registered_host()
current_filepath: str = context.data["currentFile"]
try:
from ayon_core.pipeline.workfile import save_next_version
from ayon_core.host.interfaces import SaveWorkfileOptionalData
current_filename = os.path.basename(current_filepath)
save_next_version(
description=(
f"Incremented by publishing from {current_filename}"
),
# Optimize the save by reducing needed queries for context
prepared_data=SaveWorkfileOptionalData(
project_entity=context.data["projectEntity"],
project_settings=context.data["project_settings"],
anatomy=context.data["anatomy"],
)
)
new_filepath = host.get_current_workfile()
except ImportError:
# Backwards compatibility before ayon-core 1.5.0
self.log.debug(
"Using legacy `version_up`. Update AYON core addon to "
"use newer `save_next_version` function."
)
new_filepath = version_up(current_filepath)
host.save_workfile(new_filepath)
self.log.debug(f"Incremented workfile to: {new_filepath}")