Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
3e743ac
openrv integration
Apr 13, 2023
4ec6643
Code cosmetics
BigRoy Apr 13, 2023
25669f8
Code cosmetics + cleanup
BigRoy Apr 13, 2023
7bae5de
Re-use method from host
BigRoy Apr 13, 2023
ee5944d
Remove unused function which likely came from Fusion or Clarisse inte…
BigRoy Apr 13, 2023
a37ddad
Cleanup comments
BigRoy Apr 13, 2023
751005d
Cosmetics
BigRoy Apr 13, 2023
8250f5e
Fix missing import, not sure if there was a reason it had no top import
BigRoy Apr 13, 2023
18be311
Fix typo
BigRoy Apr 13, 2023
26d6f60
Shush hound
BigRoy Apr 13, 2023
8d563b0
Remove unused `show_env`
BigRoy Apr 13, 2023
289fea4
Cleanup code
BigRoy Apr 13, 2023
b376efb
Remove debug files
BigRoy Apr 13, 2023
d10b2de
More cleanup
BigRoy Apr 13, 2023
fed5549
Return if there's no current workfile
BigRoy Apr 13, 2023
aa9766c
Cosmetics
BigRoy Apr 13, 2023
3c636d6
Cosmetics + Shush hound
BigRoy Apr 13, 2023
8d0d2bf
Remove unused function
BigRoy Apr 13, 2023
6092fa5
Merge remote-tracking branch 'upstream/develop' into openrv-integration
BigRoy Apr 13, 2023
de715e7
Cosmetics
BigRoy Apr 13, 2023
97b9c99
added missing schema
Apr 13, 2023
7a69fa5
added missing schema
Apr 13, 2023
6f50488
Cosmetics
BigRoy Apr 13, 2023
3e79ff1
Add `openrv` to hosts enum since it registers a host
BigRoy Apr 13, 2023
2310252
Use FusionPreLaunchOCIO hook as global hook for re-use with `openrv`
BigRoy Apr 13, 2023
4523416
Remove pre config hook in favor of global OCIO hook
BigRoy Apr 13, 2023
f4d69f8
Cleanup code
BigRoy Apr 13, 2023
dbec91d
Don't add to sys.path, don't clear PYTHONPATH
BigRoy Apr 13, 2023
028e85f
More specific imports
BigRoy Apr 13, 2023
d716d04
Clean up imports
BigRoy Apr 13, 2023
df7ee57
Merge branch 'develop' into openrv-integration
BigRoy Apr 13, 2023
86cc3b6
proper menu file
Apr 13, 2023
12c21e1
Cleanup file again.
BigRoy Apr 13, 2023
265d12c
Hound
BigRoy Apr 13, 2023
552c2f6
Match menu labels of other integrations + clarify arguments to `init`
BigRoy Apr 13, 2023
8303faa
Shush hound
BigRoy Apr 13, 2023
a336e1b
Remove unused variable
BigRoy Apr 13, 2023
c8df2ee
Hound
BigRoy Apr 13, 2023
bf2188f
Update menu name
BigRoy Apr 13, 2023
850cb21
Fix workfile saving with correct extension
BigRoy Apr 13, 2023
aa303b9
Hack: For now "auto-deploy" and load packages
BigRoy Apr 13, 2023
f3e357b
Update python files on deployment
BigRoy Apr 13, 2023
492ed6a
Avoid errors when no currently loaded content
BigRoy Apr 13, 2023
97a83f1
No need for default environment overrides
BigRoy Apr 13, 2023
cd34df7
Shush hound
BigRoy Apr 13, 2023
9bf9667
Fix line length
BigRoy Apr 13, 2023
f1ba2be
Shush hound
BigRoy Apr 13, 2023
0ec4afa
Shush hound
BigRoy Apr 13, 2023
a85ffd3
Shush hound
BigRoy Apr 13, 2023
48bf981
Shush hound
BigRoy Apr 13, 2023
763d4f7
Cleanup
BigRoy Apr 13, 2023
3377f32
Fix line length
BigRoy Apr 13, 2023
6503152
Hound
BigRoy Apr 13, 2023
0e1e23a
Cleanup
BigRoy Apr 13, 2023
fbea68a
Comment out unused lines which end up doing nothing
BigRoy Apr 13, 2023
759152b
Returned value was unused
BigRoy Apr 13, 2023
69a9436
Comment import + add todo
BigRoy Apr 13, 2023
ab3568d
Hound
BigRoy Apr 13, 2023
c2d156f
Cleanup cycle annotate frames logic
BigRoy Apr 13, 2023
1134aa2
Comment import + add todo
BigRoy Apr 13, 2023
189bf5e
Comment to explain we require the sorting
BigRoy Apr 13, 2023
54ea549
Don't pass emtpy list as parent
BigRoy Apr 13, 2023
fa8a964
Create dock widget only on first 'review' click and toggle view other…
BigRoy Apr 13, 2023
d734b90
Parent the OpenPype tools to RV window
BigRoy Apr 13, 2023
b079095
Cosmetics
BigRoy Apr 13, 2023
09fdae3
Cleanup imports
BigRoy Apr 13, 2023
4092069
Merge branch 'develop' into openrv-integration
BigRoy Apr 13, 2023
eb74f7e
Do nothing if there are no annotations
BigRoy Apr 13, 2023
dbcc9cc
Remove debugging method
BigRoy Apr 13, 2023
ee86ab6
Always return the session window live because there can be multiple s…
BigRoy Apr 13, 2023
dff3997
Add todo
BigRoy Apr 13, 2023
abbcca4
Only install once, not per session window
BigRoy Apr 13, 2023
ab8b0a1
Remove unused import
BigRoy Apr 13, 2023
28d352d
Works fine for multiple session windows since it initializes a class …
BigRoy Apr 13, 2023
12b17b2
Do not force show the RV console
BigRoy Apr 13, 2023
5c69925
Support loading image sequences
BigRoy Apr 13, 2023
b312019
Allow any mov or mp4 extension
BigRoy Apr 13, 2023
95aedf9
Allow loading more image extensions
BigRoy Apr 13, 2023
9887404
Add temporary hack to avoid clash with `PyOpenColorIO` in OpenPype
BigRoy Apr 13, 2023
3766241
Add todo
BigRoy Apr 13, 2023
de683b3
Do not force show review tool on launch
BigRoy Apr 13, 2023
cead75f
Simplify lib clash workaround
BigRoy Apr 13, 2023
bdde431
Add init sorted order to make "Review" the last entry in the menu.
BigRoy Apr 14, 2023
da2d988
Add OpenPype script editor (python interpreter widget) package to hel…
BigRoy Apr 14, 2023
bb8932c
Tweak organization
BigRoy Apr 14, 2023
0fd51b2
Remove forcing of asset fps/frames + support removal of containers
BigRoy Apr 14, 2023
28e27fd
Fix RV Project Settings + remove unused redundant settings
BigRoy Apr 14, 2023
267f5d5
Use OCIO schemas like other hosts
BigRoy Apr 14, 2023
e3cf566
Allow import even when OpenPype hasn't initialized/installed
BigRoy Apr 17, 2023
f38e24e
Fix typo
BigRoy Apr 17, 2023
859217f
Add checkbox active state to "review" menu entry
BigRoy Apr 17, 2023
86ee0de
Add separators to menu
BigRoy Apr 17, 2023
41c72e8
Ignore namespace attribute if it does not exist
BigRoy Apr 17, 2023
371ec04
Cleanup, move import to top + improve docstring
BigRoy Apr 17, 2023
fe1e776
Implement draft functionality to set OCIO colorspace on file load and…
BigRoy Apr 17, 2023
d1ceeff
Add active state to the menu
BigRoy Apr 17, 2023
b097044
Remove redundant check, it's already checked in other if statement
BigRoy Apr 17, 2023
1b26835
Hound
BigRoy Apr 17, 2023
262147d
Add support for open last workfile
BigRoy Apr 18, 2023
85483c5
Refactor to using new publisher
BigRoy Apr 18, 2023
367884e
Expose library loader
BigRoy Apr 18, 2023
db24d5b
Add todo
BigRoy Apr 18, 2023
8dec68b
Merge remote-tracking branch 'upstream/develop' into openrv-integration
BigRoy Apr 18, 2023
d7c4630
Define subset name correctly using templates
BigRoy Apr 18, 2023
dd664c8
Nicer label + docstring
BigRoy Apr 18, 2023
81d5d16
Add comment about a workaround
BigRoy Apr 18, 2023
fce4e7d
Cleanup `reset_frame_range` logic. Remove old `edit_in` and `edit_out`
BigRoy Apr 18, 2023
1da142c
Remove redundant adding of vendor/python
BigRoy Apr 18, 2023
26c8f29
Merge branch 'develop' into openrv-integration
BigRoy Apr 24, 2023
74779ce
Merge branch 'develop' into openrv-integration
BigRoy Apr 25, 2023
a2b37e9
Preserve predefined RV_SUPPORT_PATH paths
BigRoy Apr 25, 2023
aa74663
Install OpenPype packages to temp folder on launch + preserve predefi…
BigRoy Apr 25, 2023
4e41b48
Remove unused import
BigRoy Apr 25, 2023
0dda77b
Force `rvpkg` just to be sure it's not trying to be used interactively
BigRoy Apr 25, 2023
3493817
Merge branch 'develop' into openrv-integration
antirotor Nov 23, 2023
305efbb
:recycle: update color management settings
antirotor Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions openpype/hosts/openrv/__init__.py
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"
)
39 changes: 39 additions & 0 deletions openpype/hosts/openrv/addon.py
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"]
10 changes: 10 additions & 0 deletions openpype/hosts/openrv/api/__init__.py
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"
]
41 changes: 41 additions & 0 deletions openpype/hosts/openrv/api/commands.py
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")))

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")
23 changes: 23 additions & 0 deletions openpype/hosts/openrv/api/lib.py
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
194 changes: 194 additions & 0 deletions openpype/hosts/openrv/api/pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# -*- 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


@contextlib.contextmanager
def openrv_project_file_lock_and_undo_chunk(openrv_project_file,
undo_queue_name="Script CMD"):
"""Lock rv session and open an undo chunk during the context"""
pass


def get_path_workfile():
print("filename", rv.commands.sessionFileName())
return rv.commands.sessionFileName()
47 changes: 47 additions & 0 deletions openpype/hosts/openrv/api/review.py
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

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)
Loading