diff --git a/pype/plugins/resolve/publish/collect_instances.py b/pype/plugins/resolve/publish/collect_instances.py index 7f874a3281..d8dac70a8f 100644 --- a/pype/plugins/resolve/publish/collect_instances.py +++ b/pype/plugins/resolve/publish/collect_instances.py @@ -73,12 +73,6 @@ class CollectInstances(pyblish.api.ContextPlugin): otio_data = resolve.get_otio_clip_instance_data(track_item_data) data.update(otio_data) - file_name = "".join([asset, "_", subset, ".otio"]) - file_dir = os.path.dirname(context.data["currentFile"]) - file_path = os.path.join(file_dir, "otio", file_name) - - resolve.save_otio(otio_data["otioTimeline"], file_path) - # create instance instance = context.create_instance(**data) diff --git a/pype/plugins/resolve/publish/collect_workfile.py b/pype/plugins/resolve/publish/collect_workfile.py index cbbb1936c6..0bd1a24a46 100644 --- a/pype/plugins/resolve/publish/collect_workfile.py +++ b/pype/plugins/resolve/publish/collect_workfile.py @@ -17,61 +17,40 @@ class CollectWorkfile(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder - 0.501 def process(self, context): - exported_projet_ext = ".drp" - asset = avalon.Session["AVALON_ASSET"] - staging_dir = os.getenv("AVALON_WORKDIR") - subset = "workfile" + asset = avalon.Session["AVALON_ASSET"] + subset = "workfile" project = resolve.get_current_project() - name = project.GetName() fps = project.GetSetting("timelineFrameRate") # adding otio timeline to context otio_timeline = resolve.get_otio_complete_timeline(project) - base_name = name + exported_projet_ext - current_file = os.path.join(staging_dir, base_name) - current_file = os.path.normpath(current_file) - active_sequence = resolve.get_current_sequence() video_tracks = resolve.get_video_track_names() - # set main project attributes to context - context_data = { - "activeProject": project, - "activeSequence": active_sequence, - "otioTimeline": otio_timeline, - "videoTracks": video_tracks, - "currentFile": current_file, - "fps": fps, - } - self.log.debug("__ context_data: {}".format(pformat(context_data))) - context.data.update(context_data) - - # creating workfile representation - representation = { - 'name': exported_projet_ext[1:], - 'ext': exported_projet_ext[1:], - 'files': base_name, - "stagingDir": staging_dir, - } - instance_data = { "name": "{}_{}".format(asset, subset), "asset": asset, "subset": "{}{}".format(asset, subset.capitalize()), "item": project, - "family": "workfile", - - # source attribute - "sourcePath": current_file, - "representations": [representation] + "family": "workfile" } + # create instance with workfile instance = context.create_instance(**instance_data) + + # update context with main project attributes + context_data = { + "activeProject": project, + "activeSequence": active_sequence, + "otioTimeline": otio_timeline, + "videoTracks": video_tracks, + "currentFile": project.GetName(), + "fps": fps, + } + context.data.update(context_data) + self.log.info("Creating instance: {}".format(instance)) self.log.debug("__ instance.data: {}".format(pformat(instance.data))) - - file_name = "".join([asset, "_", subset, ".otio"]) - file_path = os.path.join(staging_dir, file_name) - resolve.save_otio(otio_timeline, file_path) + self.log.debug("__ context_data: {}".format(pformat(context_data))) diff --git a/pype/plugins/resolve/publish/extract_workfile.py b/pype/plugins/resolve/publish/extract_workfile.py new file mode 100644 index 0000000000..a88794841b --- /dev/null +++ b/pype/plugins/resolve/publish/extract_workfile.py @@ -0,0 +1,49 @@ +import os +import pyblish.api +import pype.api +from pype.hosts import resolve + +class ExtractWorkfile(pype.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))