This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft refactor workfile to new publisher - show workfile in UI
- Storing any settings/data of the workfile is not implemented yet, as such any changes you make on the Workfile instance will not yet persist on reset or reopening the publisher. (So basically similar behavior to old publisher?)
- Loading branch information
Showing
5 changed files
with
126 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Creator plugin for creating workfiles.""" | ||
from openpype.pipeline import CreatedInstance, AutoCreator | ||
from openpype.client import get_asset_by_name | ||
|
||
|
||
class CreateWorkfile(AutoCreator): | ||
"""Workfile auto-creator.""" | ||
identifier = "io.openpype.creators.resolve.workfile" | ||
label = "Workfile" | ||
family = "workfile" | ||
icon = "fa5.file" | ||
|
||
default_variant = "Main" | ||
|
||
def create(self): | ||
|
||
variant = self.default_variant | ||
current_instance = next( | ||
( | ||
instance for instance in self.create_context.instances | ||
if instance.creator_identifier == self.identifier | ||
), None) | ||
|
||
project_name = self.project_name | ||
asset_name = self.create_context.get_current_asset_name() | ||
task_name = self.create_context.get_current_task_name() | ||
host_name = self.create_context.host_name | ||
|
||
if current_instance is None: | ||
asset_doc = get_asset_by_name(project_name, asset_name) | ||
subset_name = self.get_subset_name( | ||
variant, task_name, asset_doc, project_name, host_name | ||
) | ||
data = { | ||
"asset": asset_name, | ||
"task": task_name, | ||
"variant": variant, | ||
} | ||
data.update( | ||
self.get_dynamic_data( | ||
variant, task_name, asset_doc, | ||
project_name, host_name, current_instance) | ||
) | ||
self.log.info("Auto-creating workfile instance...") | ||
current_instance = CreatedInstance( | ||
self.family, subset_name, data, self | ||
) | ||
self._add_instance_to_context(current_instance) | ||
elif ( | ||
current_instance["asset"] != asset_name | ||
or current_instance["task"] != task_name | ||
): | ||
# Update instance context if is not the same | ||
asset_doc = get_asset_by_name(project_name, asset_name) | ||
subset_name = self.get_subset_name( | ||
variant, task_name, asset_doc, project_name, host_name | ||
) | ||
current_instance["asset"] = asset_name | ||
current_instance["task"] = task_name | ||
current_instance["subset"] = subset_name | ||
|
||
def collect_instances(self): | ||
# TODO: Implement | ||
pass | ||
|
||
def update_instances(self, update_list): | ||
# TODO: Implement | ||
# This needs to be implemented to allow persisting any instance | ||
# data on resets. We'll need to decicde where to store workfile | ||
# instance data reliably. Likely metadata on the *current project*? | ||
pass |
30 changes: 30 additions & 0 deletions
30
openpype/hosts/resolve/plugins/publish/collect_current_project.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pyblish.api | ||
|
||
from openpype.hosts.resolve import api as rapi | ||
from openpype.hosts.resolve.otio import davinci_export | ||
|
||
|
||
class CollectResolveProject(pyblish.api.ContextPlugin): | ||
"""Collect the current Resolve project and current timeline data""" | ||
|
||
label = "Collect Project and Current Timeline" | ||
order = pyblish.api.CollectorOrder - 0.499 | ||
|
||
def process(self, context): | ||
project = rapi.get_current_project() | ||
fps = project.GetSetting("timelineFrameRate") | ||
video_tracks = rapi.get_video_track_names() | ||
|
||
# adding otio timeline to context | ||
otio_timeline = davinci_export.create_otio_timeline(project) | ||
|
||
# update context with main project attributes | ||
context.data.update({ | ||
# project | ||
"activeProject": project, | ||
"currentFile": project.GetName(), | ||
# timeline | ||
"otioTimeline": otio_timeline, | ||
"videoTracks": video_tracks, | ||
"fps": fps, | ||
}) |
15 changes: 15 additions & 0 deletions
15
openpype/hosts/resolve/plugins/publish/collect_workfile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pyblish.api | ||
|
||
|
||
class CollectWorkfile(pyblish.api.InstancePlugin): | ||
"""Collect the current working file into context""" | ||
|
||
families = ["workfile"] | ||
label = "Collect Workfile" | ||
order = pyblish.api.CollectorOrder - 0.49 | ||
|
||
def process(self, instance): | ||
# Backwards compatibility - workfile instances previously had 'item' | ||
# in Resolve. | ||
# TODO: Remove this if it is not needed | ||
instance.data["item"] = instance.context.data["activeProject"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
openpype/hosts/resolve/plugins/publish/precollect_workfile.py
This file was deleted.
Oops, something went wrong.