From a8482213faf987879bf40ee2d2317f626b4661bb Mon Sep 17 00:00:00 2001 From: jezscha Date: Thu, 29 Apr 2021 08:57:54 +0000 Subject: [PATCH 1/4] Create draft PR for #1324 From c70ef75042080ae0b208b1daa01c6ba20c5e5ecd Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 29 Apr 2021 12:46:53 +0200 Subject: [PATCH 2/4] Hiero: workfile plugins --- .../hiero/plugins/publish/extract_workfile.py | 50 ------------------- .../integrate_version_up_workfile.py} | 2 +- 2 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 openpype/hosts/hiero/plugins/publish/extract_workfile.py rename openpype/hosts/hiero/plugins/{publish_old_workflow/version_up_workfile.py => publish/integrate_version_up_workfile.py} (90%) diff --git a/openpype/hosts/hiero/plugins/publish/extract_workfile.py b/openpype/hosts/hiero/plugins/publish/extract_workfile.py deleted file mode 100644 index e3d60465a2..0000000000 --- a/openpype/hosts/hiero/plugins/publish/extract_workfile.py +++ /dev/null @@ -1,50 +0,0 @@ -import os -import pyblish.api -import openpype.api -from openpype.hosts import resolve - - -class ExtractWorkfile(openpype.api.Extractor): - """ - Extractor export DRP workfile file representation - """ - - label = "Extract Workfile" - order = pyblish.api.ExtractorOrder - families = ["workfile"] - hosts = ["resolve"] - - def process(self, instance): - # create representation data - if "representations" not in instance.data: - instance.data["representations"] = [] - - name = instance.data["name"] - project = instance.context.data["activeProject"] - staging_dir = self.staging_dir(instance) - - resolve_workfile_ext = ".drp" - drp_file_name = name + resolve_workfile_ext - drp_file_path = os.path.normpath( - os.path.join(staging_dir, drp_file_name)) - - # write out the drp workfile - resolve.get_project_manager().ExportProject( - project.GetName(), drp_file_path) - - # create drp workfile representation - representation_drp = { - 'name': resolve_workfile_ext[1:], - 'ext': resolve_workfile_ext[1:], - 'files': drp_file_name, - "stagingDir": staging_dir, - } - - instance.data["representations"].append(representation_drp) - - # add sourcePath attribute to instance - if not instance.data.get("sourcePath"): - instance.data["sourcePath"] = drp_file_path - - self.log.info("Added Resolve file representation: {}".format( - representation_drp)) diff --git a/openpype/hosts/hiero/plugins/publish_old_workflow/version_up_workfile.py b/openpype/hosts/hiero/plugins/publish/integrate_version_up_workfile.py similarity index 90% rename from openpype/hosts/hiero/plugins/publish_old_workflow/version_up_workfile.py rename to openpype/hosts/hiero/plugins/publish/integrate_version_up_workfile.py index ae03513d78..934e7112fa 100644 --- a/openpype/hosts/hiero/plugins/publish_old_workflow/version_up_workfile.py +++ b/openpype/hosts/hiero/plugins/publish/integrate_version_up_workfile.py @@ -2,7 +2,7 @@ from pyblish import api import openpype.api as pype -class VersionUpWorkfile(api.ContextPlugin): +class IntegrateVersionUpWorkfile(api.ContextPlugin): """Save as new workfile version""" order = api.IntegratorOrder + 10.1 From 5faa0f9f211166939536d6d00b7d1657c889f097 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 29 Apr 2021 12:47:26 +0200 Subject: [PATCH 3/4] Heiro: generate thumnails for plates, takes and workfiles --- .../plugins/publish/extract_thumbnail.py | 59 +++++++++++++++++++ .../plugins/publish/precollect_workfile.py | 43 +++++++++++++- 2 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 openpype/hosts/hiero/plugins/publish/extract_thumbnail.py diff --git a/openpype/hosts/hiero/plugins/publish/extract_thumbnail.py b/openpype/hosts/hiero/plugins/publish/extract_thumbnail.py new file mode 100644 index 0000000000..7939a1b0cd --- /dev/null +++ b/openpype/hosts/hiero/plugins/publish/extract_thumbnail.py @@ -0,0 +1,59 @@ +import os +import pyblish.api +import openpype.api + + +class ExtractThumnail(openpype.api.Extractor): + """ + Extractor for track item's tumnails + """ + + label = "Extract Thumnail" + order = pyblish.api.ExtractorOrder + # order = pyblish.api.CollectorOrder + families = ["plate", "take"] + hosts = ["hiero"] + + def process(self, instance): + # create representation data + if "representations" not in instance.data: + instance.data["representations"] = [] + + staging_dir = self.staging_dir(instance) + + self.create_thumbnail(staging_dir, instance) + + def create_thumbnail(self, staging_dir, instance): + track_item = instance.data["item"] + track_item_name = track_item.name() + + # frames + duration = track_item.sourceDuration() + frame_start = track_item.sourceIn() + self.log.debug( + "__ frame_start: `{}`, duration: `{}`".format(frame_start, duration)) + + # get thumbnail frame from the middle + thumb_frame = int(frame_start + (duration / 2)) + + thumb_file = "{}thumbnail{}{}".format( + track_item_name, thumb_frame, ".png") + thumb_path = os.path.join(staging_dir, thumb_file) + + thumbnail = track_item.thumbnail(thumb_frame).save( + thumb_path, + format='png' + ) + self.log.debug( + "__ thumb_path: `{}`, frame: `{}`".format(thumbnail, thumb_frame)) + + self.log.info("Thumnail was generated to: {}".format(thumb_path)) + thumb_representation = { + 'files': thumb_file, + 'stagingDir': staging_dir, + 'name': "thumbnail", + 'thumbnail': True, + 'ext': "png" + } + instance.data["representations"].append( + thumb_representation) diff --git a/openpype/hosts/hiero/plugins/publish/precollect_workfile.py b/openpype/hosts/hiero/plugins/publish/precollect_workfile.py index 22201cafe3..6f665e857d 100644 --- a/openpype/hosts/hiero/plugins/publish/precollect_workfile.py +++ b/openpype/hosts/hiero/plugins/publish/precollect_workfile.py @@ -1,10 +1,13 @@ +import os import pyblish.api import hiero.ui from openpype.hosts.hiero import api as phiero from avalon import api as avalon from pprint import pformat from openpype.hosts.hiero.otio import hiero_export - +from Qt.QtGui import QPixmap +import tempfile +import hiero.ui class PrecollectWorkfile(pyblish.api.ContextPlugin): """Inject the current working file into context""" @@ -23,12 +26,46 @@ class PrecollectWorkfile(pyblish.api.ContextPlugin): # adding otio timeline to context otio_timeline = hiero_export.create_otio_timeline() + # get workfile thumnail paths + tmp_staging = tempfile.mkdtemp(prefix="pyblish_tmp_") + thumbnail_name = "workfile_thumbnail.png" + thumbnail_path = os.path.join(tmp_staging, thumbnail_name) + + # search for all windows with name of actual sequence + _windows = [w for w in hiero.ui.windowManager().windows() + if active_timeline.name() in w.windowTitle()] + + # export window to thumb path + QPixmap.grabWidget(_windows[-1]).save(thumbnail_path, 'png') + + # thumbnail + thumb_representation = { + 'files': thumbnail_name, + 'stagingDir': tmp_staging, + 'name': "thumbnail", + 'thumbnail': True, + 'ext': "png" + } + + # get workfile paths + curent_file = project.path() + staging_dir, base_name = os.path.split(curent_file) + + # creating workfile representation + workfile_representation = { + 'name': 'hrox', + 'ext': 'hrox', + 'files': base_name, + "stagingDir": staging_dir, + } + instance_data = { "name": "{}_{}".format(asset, subset), "asset": asset, "subset": "{}{}".format(asset, subset.capitalize()), "item": project, - "family": "workfile" + "family": "workfile", + "representations": [workfile_representation, thumb_representation] } # create instance with workfile @@ -38,7 +75,7 @@ class PrecollectWorkfile(pyblish.api.ContextPlugin): context_data = { "activeProject": project, "otioTimeline": otio_timeline, - "currentFile": project.path(), + "currentFile": curent_file, "fps": fps, } context.data.update(context_data) From 376c4bfa2d8a1a8370e285b34263eef7ae9a4031 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 29 Apr 2021 12:50:08 +0200 Subject: [PATCH 4/4] Hound: suggestions --- openpype/hosts/hiero/plugins/publish/extract_thumbnail.py | 4 ++-- openpype/hosts/hiero/plugins/publish/precollect_workfile.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/hiero/plugins/publish/extract_thumbnail.py b/openpype/hosts/hiero/plugins/publish/extract_thumbnail.py index 7939a1b0cd..d12e7665bf 100644 --- a/openpype/hosts/hiero/plugins/publish/extract_thumbnail.py +++ b/openpype/hosts/hiero/plugins/publish/extract_thumbnail.py @@ -10,7 +10,6 @@ class ExtractThumnail(openpype.api.Extractor): label = "Extract Thumnail" order = pyblish.api.ExtractorOrder - # order = pyblish.api.CollectorOrder families = ["plate", "take"] hosts = ["hiero"] @@ -31,7 +30,8 @@ class ExtractThumnail(openpype.api.Extractor): duration = track_item.sourceDuration() frame_start = track_item.sourceIn() self.log.debug( - "__ frame_start: `{}`, duration: `{}`".format(frame_start, duration)) + "__ frame_start: `{}`, duration: `{}`".format( + frame_start, duration)) # get thumbnail frame from the middle thumb_frame = int(frame_start + (duration / 2)) diff --git a/openpype/hosts/hiero/plugins/publish/precollect_workfile.py b/openpype/hosts/hiero/plugins/publish/precollect_workfile.py index 6f665e857d..bc4ef7e150 100644 --- a/openpype/hosts/hiero/plugins/publish/precollect_workfile.py +++ b/openpype/hosts/hiero/plugins/publish/precollect_workfile.py @@ -7,7 +7,6 @@ from pprint import pformat from openpype.hosts.hiero.otio import hiero_export from Qt.QtGui import QPixmap import tempfile -import hiero.ui class PrecollectWorkfile(pyblish.api.ContextPlugin): """Inject the current working file into context"""