Fix Version follow up from Workfile set by hosts.

This commit is contained in:
robin@ynput.io 2025-01-29 12:04:38 +01:00
parent 283465bbb7
commit d25c4701d1
2 changed files with 20 additions and 2 deletions

View file

@ -858,13 +858,24 @@ class Creator(BaseCreator):
["CollectAnatomyInstanceData"]
["follow_workfile_version"]
)
follow_version_hosts = (
publish_settings
["CollectSceneVersion"]
["hosts"]
)
current_host = create_ctx.host.name
follow_workfile_version = (
follow_workfile_version and
current_host in follow_version_hosts
)
# Gather version number provided from the instance.
current_workfile = create_ctx.get_current_workfile_path()
version = instance.get("version")
# If follow workfile, gather version from workfile path.
if version is None and follow_workfile_version:
current_workfile = self.create_context.get_current_workfile_path()
if version is None and follow_workfile_version and current_workfile:
workfile_version = get_version_from_path(current_workfile)
version = int(workfile_version)

View file

@ -46,6 +46,13 @@ class CollectSceneVersion(pyblish.api.ContextPlugin):
self.log.debug("Skipping for headless publishing")
return
if context.data["hostName"] not in self.hosts:
self.log.debug(
f"Host {context.data['hostName']} is"
" not setup for following version."
)
return
if not context.data.get('currentFile'):
self.log.error("Cannot get current workfile path. "
"Make sure your scene is saved.")