Merge branch '2.x/develop' into feature/maya-tile-rendering

This commit is contained in:
Ondřej Samohel 2020-08-10 14:28:40 +02:00
commit 3040eed159
No known key found for this signature in database
GPG key ID: 8A29C663C672C2B7
37 changed files with 1101 additions and 724 deletions

View file

@ -12,7 +12,7 @@ class CollectRenderPath(pyblish.api.InstancePlugin):
# Presets
anatomy_render_key = None
anatomy_publish_render_key = None
publish_render_metadata = None
def process(self, instance):
anatomy = instance.context.data["anatomy"]
@ -28,7 +28,7 @@ class CollectRenderPath(pyblish.api.InstancePlugin):
# get anatomy rendering keys
anatomy_render_key = self.anatomy_render_key or "render"
anatomy_publish_render_key = self.anatomy_publish_render_key or "render"
publish_render_metadata = self.publish_render_metadata or "render"
# get folder and path for rendering images from celaction
render_dir = anatomy_filled[anatomy_render_key]["folder"]
@ -46,8 +46,11 @@ class CollectRenderPath(pyblish.api.InstancePlugin):
instance.data["path"] = render_path
# get anatomy for published renders folder path
if anatomy_filled.get(anatomy_publish_render_key):
instance.data["publishRenderFolder"] = anatomy_filled[
anatomy_publish_render_key]["folder"]
if anatomy_filled.get(publish_render_metadata):
instance.data["publishRenderMetadataFolder"] = anatomy_filled[
publish_render_metadata]["folder"]
self.log.info("Metadata render path: `{}`".format(
instance.data["publishRenderMetadataFolder"]
))
self.log.info(f"Render output path set to: `{render_path}`")

View file

@ -1,5 +1,5 @@
import shutil
import re
import pype
import pyblish.api
@ -12,57 +12,9 @@ class VersionUpScene(pyblish.api.ContextPlugin):
def process(self, context):
current_file = context.data.get('currentFile')
v_up = get_version_up(current_file)
v_up = pype.lib.version_up(current_file)
self.log.debug('Current file is: {}'.format(current_file))
self.log.debug('Version up: {}'.format(v_up))
shutil.copy2(current_file, v_up)
self.log.info('Scene saved into new version: {}'.format(v_up))
def version_get(string, prefix, suffix=None):
"""Extract version information from filenames used by DD (and Weta, apparently)
These are _v# or /v# or .v# where v is a prefix string, in our case
we use "v" for render version and "c" for camera track version.
See the version.py and camera.py plugins for usage."""
if string is None:
raise ValueError("Empty version string - no match")
regex = r"[/_.]{}\d+".format(prefix)
matches = re.findall(regex, string, re.IGNORECASE)
if not len(matches):
msg = f"No `_{prefix}#` found in `{string}`"
raise ValueError(msg)
return (matches[-1:][0][1], re.search(r"\d+", matches[-1:][0]).group())
def version_set(string, prefix, oldintval, newintval):
"""Changes version information from filenames used by DD (and Weta, apparently)
These are _v# or /v# or .v# where v is a prefix string, in our case
we use "v" for render version and "c" for camera track version.
See the version.py and camera.py plugins for usage."""
regex = r"[/_.]{}\d+".format(prefix)
matches = re.findall(regex, string, re.IGNORECASE)
if not len(matches):
return ""
# Filter to retain only version strings with matching numbers
matches = filter(lambda s: int(s[2:]) == oldintval, matches)
# Replace all version strings with matching numbers
for match in matches:
# use expression instead of expr so 0 prefix does not make octal
fmt = "%%(#)0%dd" % (len(match) - 2)
newfullvalue = match[0] + prefix + str(fmt % {"#": newintval})
string = re.sub(match, newfullvalue, string)
return string
def get_version_up(path):
""" Returns the next version of the path """
(prefix, v) = version_get(path, 'v')
v = int(v)
return version_set(path, prefix, v, v + 1)