Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

After Effects: base integration with loaders #667

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
74 changes: 74 additions & 0 deletions pype/hosts/aftereffects/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import os
import sys

from avalon import api, io
from avalon.vendor import Qt
from pype import lib
import pyblish.api


def check_inventory():
if not lib.any_outdated():
return

host = api.registered_host()
outdated_containers = []
for container in host.ls():
representation = container['representation']
representation_doc = io.find_one(
{
"_id": io.ObjectId(representation),
"type": "representation"
},
projection={"parent": True}
)
if representation_doc and not lib.is_latest(representation_doc):
outdated_containers.append(container)

# Warn about outdated containers.
print("Starting new QApplication..")
app = Qt.QtWidgets.QApplication(sys.argv)

message_box = Qt.QtWidgets.QMessageBox()
message_box.setIcon(Qt.QtWidgets.QMessageBox.Warning)
msg = "There are outdated containers in the scene."
message_box.setText(msg)
message_box.exec_()

# Garbage collect QApplication.
del app


def application_launch():
check_inventory()


def install():
print("Installing Pype config...")

plugins_directory = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
"plugins",
"aftereffects"
)

pyblish.api.register_plugin_path(
os.path.join(plugins_directory, "publish")
)
api.register_plugin_path(
api.Loader, os.path.join(plugins_directory, "load")
)
api.register_plugin_path(
api.Creator, os.path.join(plugins_directory, "create")
)

pyblish.api.register_callback(
"instanceToggled", on_pyblish_instance_toggled
)

api.on("application.launched", application_launch)


def on_pyblish_instance_toggled(instance, old_value, new_value):
"""Toggle layer visibility on instance toggles."""
instance[0].Visible = new_value
64 changes: 64 additions & 0 deletions pype/modules/websocket_server/hosts/aftereffects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from pype.api import Logger
from wsrpc_aiohttp import WebSocketRoute
import functools

import avalon.aftereffects as aftereffects

log = Logger().get_logger("WebsocketServer")


class AfterEffects(WebSocketRoute):
"""
One route, mimicking external application (like Harmony, etc).
All functions could be called from client.
'do_notify' function calls function on the client - mimicking
notification after long running job on the server or similar
"""
instance = None

def init(self, **kwargs):
# Python __init__ must be return "self".
# This method might return anything.
log.debug("someone called AfterEffects route")
self.instance = self
return kwargs

# server functions
async def ping(self):
log.debug("someone called AfterEffects route ping")

# This method calls function on the client side
# client functions

async def read(self):
log.debug("aftereffects.read client calls server server calls "
"aftereffects client")
return await self.socket.call('aftereffects.read')

# panel routes for tools
async def creator_route(self):
self._tool_route("creator")

async def workfiles_route(self):
self._tool_route("workfiles")

async def loader_route(self):
self._tool_route("loader")

async def publish_route(self):
self._tool_route("publish")

async def sceneinventory_route(self):
self._tool_route("sceneinventory")

async def projectmanager_route(self):
self._tool_route("projectmanager")

def _tool_route(self, tool_name):
"""The address accessed when clicking on the buttons."""
partial_method = functools.partial(aftereffects.show, tool_name)

aftereffects.execute_in_main_thread(partial_method)

# Required return statement.
return "nothing"
Loading