This repository was archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
OpenRV integration #4839
Closed
Closed
OpenRV integration #4839
Changes from 6 commits
Commits
Show all changes
116 commits
Select commit
Hold shift + click to select a range
3e743ac
openrv integration
4ec6643
Code cosmetics
BigRoy 25669f8
Code cosmetics + cleanup
BigRoy 7bae5de
Re-use method from host
BigRoy ee5944d
Remove unused function which likely came from Fusion or Clarisse inte…
BigRoy a37ddad
Cleanup comments
BigRoy 751005d
Cosmetics
BigRoy 8250f5e
Fix missing import, not sure if there was a reason it had no top import
BigRoy 18be311
Fix typo
BigRoy 26d6f60
Shush hound
BigRoy 8d563b0
Remove unused `show_env`
BigRoy 289fea4
Cleanup code
BigRoy b376efb
Remove debug files
BigRoy d10b2de
More cleanup
BigRoy fed5549
Return if there's no current workfile
BigRoy aa9766c
Cosmetics
BigRoy 3c636d6
Cosmetics + Shush hound
BigRoy 8d0d2bf
Remove unused function
BigRoy 6092fa5
Merge remote-tracking branch 'upstream/develop' into openrv-integration
BigRoy de715e7
Cosmetics
BigRoy 97b9c99
added missing schema
7a69fa5
added missing schema
6f50488
Cosmetics
BigRoy 3e79ff1
Add `openrv` to hosts enum since it registers a host
BigRoy 2310252
Use FusionPreLaunchOCIO hook as global hook for re-use with `openrv`
BigRoy 4523416
Remove pre config hook in favor of global OCIO hook
BigRoy f4d69f8
Cleanup code
BigRoy dbec91d
Don't add to sys.path, don't clear PYTHONPATH
BigRoy 028e85f
More specific imports
BigRoy d716d04
Clean up imports
BigRoy df7ee57
Merge branch 'develop' into openrv-integration
BigRoy 86cc3b6
proper menu file
12c21e1
Cleanup file again.
BigRoy 265d12c
Hound
BigRoy 552c2f6
Match menu labels of other integrations + clarify arguments to `init`
BigRoy 8303faa
Shush hound
BigRoy a336e1b
Remove unused variable
BigRoy c8df2ee
Hound
BigRoy bf2188f
Update menu name
BigRoy 850cb21
Fix workfile saving with correct extension
BigRoy aa303b9
Hack: For now "auto-deploy" and load packages
BigRoy f3e357b
Update python files on deployment
BigRoy 492ed6a
Avoid errors when no currently loaded content
BigRoy 97a83f1
No need for default environment overrides
BigRoy cd34df7
Shush hound
BigRoy 9bf9667
Fix line length
BigRoy f1ba2be
Shush hound
BigRoy 0ec4afa
Shush hound
BigRoy a85ffd3
Shush hound
BigRoy 48bf981
Shush hound
BigRoy 763d4f7
Cleanup
BigRoy 3377f32
Fix line length
BigRoy 6503152
Hound
BigRoy 0e1e23a
Cleanup
BigRoy fbea68a
Comment out unused lines which end up doing nothing
BigRoy 759152b
Returned value was unused
BigRoy 69a9436
Comment import + add todo
BigRoy ab3568d
Hound
BigRoy c2d156f
Cleanup cycle annotate frames logic
BigRoy 1134aa2
Comment import + add todo
BigRoy 189bf5e
Comment to explain we require the sorting
BigRoy 54ea549
Don't pass emtpy list as parent
BigRoy fa8a964
Create dock widget only on first 'review' click and toggle view other…
BigRoy d734b90
Parent the OpenPype tools to RV window
BigRoy b079095
Cosmetics
BigRoy 09fdae3
Cleanup imports
BigRoy 4092069
Merge branch 'develop' into openrv-integration
BigRoy eb74f7e
Do nothing if there are no annotations
BigRoy dbcc9cc
Remove debugging method
BigRoy ee86ab6
Always return the session window live because there can be multiple s…
BigRoy dff3997
Add todo
BigRoy abbcca4
Only install once, not per session window
BigRoy ab8b0a1
Remove unused import
BigRoy 28d352d
Works fine for multiple session windows since it initializes a class …
BigRoy 12b17b2
Do not force show the RV console
BigRoy 5c69925
Support loading image sequences
BigRoy b312019
Allow any mov or mp4 extension
BigRoy 95aedf9
Allow loading more image extensions
BigRoy 9887404
Add temporary hack to avoid clash with `PyOpenColorIO` in OpenPype
BigRoy 3766241
Add todo
BigRoy de683b3
Do not force show review tool on launch
BigRoy cead75f
Simplify lib clash workaround
BigRoy bdde431
Add init sorted order to make "Review" the last entry in the menu.
BigRoy da2d988
Add OpenPype script editor (python interpreter widget) package to hel…
BigRoy bb8932c
Tweak organization
BigRoy 0fd51b2
Remove forcing of asset fps/frames + support removal of containers
BigRoy 28e27fd
Fix RV Project Settings + remove unused redundant settings
BigRoy 267f5d5
Use OCIO schemas like other hosts
BigRoy e3cf566
Allow import even when OpenPype hasn't initialized/installed
BigRoy f38e24e
Fix typo
BigRoy 859217f
Add checkbox active state to "review" menu entry
BigRoy 86ee0de
Add separators to menu
BigRoy 41c72e8
Ignore namespace attribute if it does not exist
BigRoy 371ec04
Cleanup, move import to top + improve docstring
BigRoy fe1e776
Implement draft functionality to set OCIO colorspace on file load and…
BigRoy d1ceeff
Add active state to the menu
BigRoy b097044
Remove redundant check, it's already checked in other if statement
BigRoy 1b26835
Hound
BigRoy 262147d
Add support for open last workfile
BigRoy 85483c5
Refactor to using new publisher
BigRoy 367884e
Expose library loader
BigRoy db24d5b
Add todo
BigRoy 8dec68b
Merge remote-tracking branch 'upstream/develop' into openrv-integration
BigRoy d7c4630
Define subset name correctly using templates
BigRoy dd664c8
Nicer label + docstring
BigRoy 81d5d16
Add comment about a workaround
BigRoy fce4e7d
Cleanup `reset_frame_range` logic. Remove old `edit_in` and `edit_out`
BigRoy 1da142c
Remove redundant adding of vendor/python
BigRoy 26c8f29
Merge branch 'develop' into openrv-integration
BigRoy 74779ce
Merge branch 'develop' into openrv-integration
BigRoy a2b37e9
Preserve predefined RV_SUPPORT_PATH paths
BigRoy aa74663
Install OpenPype packages to temp folder on launch + preserve predefi…
BigRoy 4e41b48
Remove unused import
BigRoy 0dda77b
Force `rvpkg` just to be sure it's not trying to be used interactively
BigRoy 3493817
Merge branch 'develop' into openrv-integration
antirotor 305efbb
:recycle: update color management settings
antirotor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,10 @@ | ||
| from .addon import ( | ||
| OpenRVAddon, | ||
| OPENRV_ROOT_DIR | ||
| ) | ||
|
|
||
|
|
||
| __all__ = ( | ||
| "OpenRVAddon", | ||
| "OPENRV_ROOT_DIR" | ||
| ) |
This file contains hidden or 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,39 @@ | ||
| import os | ||
| import sys | ||
| from openpype.modules import OpenPypeModule | ||
| from openpype.modules.interfaces import IHostAddon | ||
|
|
||
| OPENRV_ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
|
|
||
| class OpenRVAddon(OpenPypeModule, IHostAddon): | ||
| name = "openrv" | ||
| host_name = "openrv" | ||
|
|
||
| def initialize(self, module_settings): | ||
| self.enabled = True | ||
|
|
||
| def add_implementation_envs(self, env, app): | ||
| """Modify environments to contain all required for implementation.""" | ||
| vendor_python = os.path.join(os.getenv("OPENPYPE_ROOT"), | ||
| "vendor", | ||
| "python") | ||
| sys.path.insert(0, vendor_python) | ||
|
|
||
| # Set default environments if are not set via settings | ||
| defaults = { | ||
| "OPENPYPE_LOG_NO_COLORS": "True" | ||
| } | ||
| for key, value in defaults.items(): | ||
| if not env.get(key): | ||
| env[key] = value | ||
|
|
||
| def get_launch_hook_paths(self, app): | ||
| if app.host_name != self.host_name: | ||
| return [] | ||
| return [ | ||
| os.path.join(OPENRV_ROOT_DIR, "hooks") | ||
| ] | ||
|
|
||
| def get_workfile_extensions(self): | ||
| return [".rv"] | ||
This file contains hidden or 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,10 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """OpenRV OpenPype host API.""" | ||
|
|
||
| from .pipeline import ( | ||
| OpenRVHost | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "OpenRVHost" | ||
| ] |
This file contains hidden or 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,41 @@ | ||
| import logging | ||
|
|
||
| import rv | ||
| from openpype.pipeline.context_tools import get_current_project_asset | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def reset_frame_range(): | ||
| """ Set timeline frame range. | ||
| """ | ||
| asset_doc = get_current_project_asset() | ||
| asset_data = asset_doc["data"] | ||
|
|
||
| frame_start = int(asset_data.get( | ||
| "frameStart", | ||
| asset_data.get("edit_in"))) | ||
|
|
||
| frame_end = int(asset_data.get( | ||
| "frameEnd", | ||
| asset_data.get("edit_out"))) | ||
BigRoy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| rv.commands.setFrameStart(frame_start) | ||
| rv.commands.setFrameEnd(frame_end) | ||
| rv.commands.setFrame(frame_start) | ||
|
|
||
| log.info("Project frame range set") | ||
|
|
||
|
|
||
| def set_session_fps(): | ||
| """ Set session fps. | ||
| """ | ||
| asset_doc = get_current_project_asset() | ||
| asset_data = asset_doc["data"] | ||
| fps = float(asset_data.get("fps", 25)) | ||
| rv.commands.setFPS(fps) | ||
|
|
||
|
|
||
| def create_support_ticket(): | ||
| import webbrowser | ||
| webbrowser.open("http://localhost:5400/tickets/create_tickets") | ||
BigRoy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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,23 @@ | ||
| import contextlib | ||
|
|
||
|
|
||
| @contextlib.contextmanager | ||
| def maintained_selection(): | ||
| return | ||
|
|
||
|
|
||
| @contextlib.contextmanager | ||
| def command_batch(name): | ||
| return | ||
|
|
||
|
|
||
| def group_member_of_type(group_node, member_type): | ||
| """ | ||
| usage layout_stack = group_member_of_type(sequence_layout, "RVStack") | ||
| :param group_node: | ||
| :param member_type: | ||
| :return: | ||
| """ | ||
| for node in rv.commands.nodesInGroup(group_node): | ||
| if rv.commands.nodeType(node) == member_type: | ||
| return node |
This file contains hidden or 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,182 @@ | ||
| # -*- coding: utf-8 -*- | ||
| import contextlib | ||
| import os | ||
| from collections import OrderedDict | ||
|
|
||
| import pyblish | ||
| import rv | ||
|
|
||
| from openpype.host import HostBase, ILoadHost, IWorkfileHost | ||
| from openpype.hosts.openrv import OPENRV_ROOT_DIR | ||
| from openpype.pipeline import ( | ||
| register_loader_plugin_path, | ||
| register_inventory_action_path, | ||
| register_creator_plugin_path, | ||
| AVALON_CONTAINER_ID, | ||
| ) | ||
| from . import lib | ||
|
|
||
| PLUGINS_DIR = os.path.join(OPENRV_ROOT_DIR, "plugins") | ||
| PUBLISH_PATH = os.path.join(PLUGINS_DIR, "publish") | ||
| LOAD_PATH = os.path.join(PLUGINS_DIR, "load") | ||
| CREATE_PATH = os.path.join(PLUGINS_DIR, "create") | ||
| INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory") | ||
|
|
||
| OPENPYPE_ATTR_PREFIX = "openpype" | ||
|
|
||
|
|
||
| class OpenRVHost(HostBase, IWorkfileHost, ILoadHost): | ||
| name = "openrv" | ||
|
|
||
| def __init__(self): | ||
| super(OpenRVHost, self).__init__() | ||
| self._op_events = {} | ||
|
|
||
| def install(self): | ||
| pyblish.api.register_plugin_path(PUBLISH_PATH) | ||
| pyblish.api.register_host("openrv") | ||
|
|
||
| register_loader_plugin_path(LOAD_PATH) | ||
| register_creator_plugin_path(CREATE_PATH) | ||
| register_inventory_action_path(INVENTORY_PATH) | ||
|
|
||
| def open_workfile(self, filepath): | ||
| return rv.commands.addSources([filepath]) | ||
|
|
||
| def save_workfile(self, filepath=None): | ||
| return rv.commands.saveSession(filepath) | ||
|
|
||
| def work_root(self, session): | ||
| work_dir = session.get("AVALON_WORKDIR") | ||
| scene_dir = session.get("AVALON_SCENEDIR") | ||
| if scene_dir: | ||
| return os.path.join(work_dir, scene_dir) | ||
| else: | ||
| return work_dir | ||
|
|
||
| def get_current_workfile(self): | ||
| return rv.commands.sessionFileName() | ||
|
|
||
| def workfile_has_unsaved_changes(self): | ||
| # dont ask to save if we are on the startup scene without a name | ||
| # set to untitled project and return False | ||
| print("filename", rv.commands.sessionFileName()) | ||
| return False | ||
|
|
||
| def get_workfile_extensions(self): | ||
| return [".rv"] | ||
|
|
||
| def get_containers(self): | ||
| """Get containers. | ||
| """ | ||
| all_items = gather_containers() | ||
| for rvnode in all_items: | ||
| parsed = parse_container(rvnode) | ||
| yield parsed | ||
|
|
||
| @contextlib.contextmanager | ||
| def maintained_selection(self): | ||
| with lib.maintained_selection(): | ||
| yield | ||
|
|
||
|
|
||
| def imprint(node, data): | ||
| """Store string attributes with value on a node | ||
|
|
||
| Args: | ||
| node (object): The node to imprint data on. | ||
| data (dict): Key value pairs of attributes to create. | ||
| group (str): The Group to add the attributes to. | ||
|
|
||
| Returns: | ||
| None | ||
|
|
||
| """ | ||
| for attr, value in data.items(): | ||
| # Create and set the attribute | ||
| prop = "{}.{}.{}".format(node, OPENPYPE_ATTR_PREFIX, attr) | ||
| if not rv.commands.propertyExists(prop): | ||
| rv.commands.newProperty(prop, rv.commands.StringType, 1) | ||
| rv.commands.setStringProperty(prop, [str(value)], True) | ||
|
|
||
| return | ||
|
|
||
|
|
||
| def imprint_container(node, name, namespace, context, loader): | ||
| """Imprint `node` with container metadata. | ||
|
|
||
| Arguments: | ||
| node (object): The node to containerise. | ||
| name (str): Name of resulting assembly | ||
| namespace (str): Namespace under which to host container | ||
| context (dict): Asset information | ||
| loader (str): Name of loader used to produce this container. | ||
|
|
||
| Returns: | ||
| None | ||
|
|
||
| """ | ||
|
|
||
| data = [ | ||
| ("schema", "openpype:container-2.0"), | ||
| ("id", AVALON_CONTAINER_ID), | ||
| ("name", name), | ||
| ("namespace", namespace), | ||
| ("loader", loader), | ||
| ("representation", context["representation"]["_id"]) | ||
| ] | ||
|
|
||
| # We use an OrderedDict to make sure the attributes | ||
| # are always created in the same order. This is solely | ||
| # to make debugging easier when reading the values in | ||
| # the attribute editor. | ||
| imprint(node, OrderedDict(data)) | ||
|
|
||
|
|
||
| def parse_container(node): | ||
| """Returns imprinted container data of a tool | ||
|
|
||
| This reads the imprinted data from `imprint_container`. | ||
|
|
||
| """ | ||
| # If not all required data return None | ||
| required = ['id', 'schema', 'name', | ||
| 'namespace', 'loader', 'representation'] | ||
|
|
||
| data = {} | ||
| for key in required: | ||
| attr = node + "." + OPENPYPE_ATTR_PREFIX + "." + key | ||
| if not rv.commands.propertyExists(attr): | ||
| return | ||
|
|
||
| value = rv.commands.getStringProperty(attr)[0] | ||
| data[key] = value | ||
|
|
||
| # Store the node's name | ||
| data["objectName"] = str(node) | ||
|
|
||
| # Store reference to the node object | ||
| data["node"] = node | ||
|
|
||
| return data | ||
|
|
||
|
|
||
| def gather_containers(): | ||
| """gathers all rv nodes list | ||
| """ | ||
| all_files = [] | ||
| all_nodes = rv.commands.nodes() | ||
| for node in all_nodes: | ||
| prop = node + "." + OPENPYPE_ATTR_PREFIX + ".schema" | ||
| if rv.commands.propertyExists(prop): | ||
| all_files.append(node) | ||
| return set(all_files) | ||
|
|
||
|
|
||
| def get_containers(): | ||
| """Get containers. | ||
| """ | ||
| all_items = gather_containers() | ||
| for rvnode in all_items: | ||
| parsed = parse_container(rvnode) | ||
| yield parsed |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These functions are basically untested at this stage as far as I know. |
This file contains hidden or 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,47 @@ | ||
| """review code""" | ||
| import os | ||
|
|
||
| import rv | ||
|
|
||
|
|
||
| def get_path_annotated_frame(frame=None, asset=None, asset_folder=None): | ||
| """Get path for annotations | ||
| """ | ||
| # TODO: This should be less hardcoded | ||
| filename = os.path.normpath( | ||
| "{}/pyblish/exports/annotated_frames/annotate_{}_{}.jpg".format( | ||
| str(asset_folder), | ||
| str(asset), | ||
| str(frame) | ||
| ) | ||
| ) | ||
| return filename | ||
|
|
||
|
|
||
| def extract_annotated_frame(filepath=None): | ||
| """Export frame to file | ||
| """ | ||
| if filepath: | ||
| return rv.commands.exportCurrentFrame(filepath) | ||
|
|
||
|
|
||
| def review_attributes(node=None): | ||
| prop_status = node + ".openpype" + ".review_status" | ||
| prop_comment = node + ".openpype" + ".review_comment" | ||
|
|
||
|
|
||
| def get_review_attribute(node=None, attribute=None): | ||
| attr = node + ".openpype" + "." + attribute | ||
| return rv.commands.getStringProperty(attr)[0] | ||
|
|
||
|
|
||
| def write_review_attribute(node=None, attribute=None, att_value=None): | ||
| att_prop = node + ".openpype" + ".{}".format(attribute) | ||
| if not rv.commands.propertyExists(att_prop): | ||
| rv.commands.newProperty(att_prop, rv.commands.StringType, 1) | ||
| rv.commands.setStringProperty(att_prop, [str(att_value)], True) | ||
|
|
||
|
|
||
| def export_current_view_frame(frame=None, export_path=None): | ||
| rv.commands.setFrame(int(frame)) | ||
| rv.commands.exportCurrentFrame(export_path) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.