mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #668 from pypeclub/feature/612_tvpaint_integration
TVPaint integration
This commit is contained in:
commit
b32ef567f0
4 changed files with 122 additions and 7 deletions
|
|
@ -1,15 +1,13 @@
|
|||
import os
|
||||
import shutil
|
||||
from pype.lib import PypeHook
|
||||
from pype.api import (
|
||||
Anatomy,
|
||||
Logger
|
||||
)
|
||||
import platform
|
||||
import pype.lib
|
||||
from pype.api import Anatomy, Logger
|
||||
import getpass
|
||||
import avalon.api
|
||||
|
||||
|
||||
class TvpaintPrelaunchHook(PypeHook):
|
||||
class TvpaintPrelaunchHook(pype.lib.PypeHook):
|
||||
"""
|
||||
Workfile preparation hook
|
||||
"""
|
||||
|
|
@ -23,10 +21,22 @@ class TvpaintPrelaunchHook(PypeHook):
|
|||
|
||||
self.signature = "( {} )".format(self.__class__.__name__)
|
||||
|
||||
def install_pywin(self):
|
||||
if platform.system().lower() != "windows":
|
||||
return
|
||||
|
||||
try:
|
||||
from win32com.shell import shell
|
||||
except Exception:
|
||||
output = pype.lib._subprocess(["pip", "install", "pywin32==227"])
|
||||
self.log.info(output)
|
||||
|
||||
def execute(self, *args, env: dict = None) -> bool:
|
||||
if not env:
|
||||
env = os.environ
|
||||
|
||||
self.install_pywin()
|
||||
|
||||
# get context variables
|
||||
project_name = env["AVALON_PROJECT"]
|
||||
asset_name = env["AVALON_ASSET"]
|
||||
|
|
|
|||
|
|
@ -1 +1,31 @@
|
|||
kwargs = None
|
||||
import os
|
||||
import logging
|
||||
|
||||
from avalon.tvpaint.communication_server import register_localization_file
|
||||
import avalon.api
|
||||
import pyblish.api
|
||||
from pype import PLUGINS_DIR
|
||||
|
||||
log = logging.getLogger("pype.hosts.tvpaint")
|
||||
|
||||
PUBLISH_PATH = os.path.join(PLUGINS_DIR, "tvpaint", "publish")
|
||||
LOAD_PATH = os.path.join(PLUGINS_DIR, "tvpaint", "load")
|
||||
CREATE_PATH = os.path.join(PLUGINS_DIR, "tvpaint", "create")
|
||||
|
||||
|
||||
def install():
|
||||
log.info("Pype - Installing TVPaint integration")
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
localization_file = os.path.join(current_dir, "avalon.loc")
|
||||
register_localization_file(localization_file)
|
||||
|
||||
pyblish.api.register_plugin_path(PUBLISH_PATH)
|
||||
avalon.api.register_plugin_path(avalon.api.Loader, LOAD_PATH)
|
||||
avalon.api.register_plugin_path(avalon.api.Creator, CREATE_PATH)
|
||||
|
||||
|
||||
def uninstall():
|
||||
log.info("Pype - Uninstalling TVPaint integration")
|
||||
pyblish.api.deregister_plugin_path(PUBLISH_PATH)
|
||||
avalon.api.deregister_plugin_path(avalon.api.Loader, LOAD_PATH)
|
||||
avalon.api.deregister_plugin_path(avalon.api.Creator, CREATE_PATH)
|
||||
|
|
|
|||
37
pype/hosts/tvpaint/avalon.loc
Normal file
37
pype/hosts/tvpaint/avalon.loc
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#-------------------------------------------------
|
||||
#------------ AVALON PLUGIN LOC FILE -------------
|
||||
#-------------------------------------------------
|
||||
|
||||
#Language : English
|
||||
#Version : 1.0
|
||||
#Date : 27/10/2020
|
||||
|
||||
#-------------------------------------------------
|
||||
#------------ COMMON -----------------------------
|
||||
#-------------------------------------------------
|
||||
|
||||
$100 "Pype Tools"
|
||||
|
||||
$10010 "Workfiles"
|
||||
$10020 "Load"
|
||||
$10030 "Create"
|
||||
$10040 "Scene inventory"
|
||||
$10050 "Publish"
|
||||
$10060 "Library"
|
||||
|
||||
#------------ Help -------------------------------
|
||||
|
||||
$20010 "Open workfiles tool"
|
||||
$20020 "Open loader tool"
|
||||
$20030 "Open creator tool"
|
||||
$20040 "Open scene inventory tool"
|
||||
$20050 "Open publisher"
|
||||
$20060 "Open library loader tool"
|
||||
|
||||
#------------ Errors -----------------------------
|
||||
|
||||
$30001 "Can't Open Requester !"
|
||||
|
||||
#-------------------------------------------------
|
||||
#------------ END --------------------------------
|
||||
#-------------------------------------------------
|
||||
38
pype/plugins/tvpaint/load/load_image.py
Normal file
38
pype/plugins/tvpaint/load/load_image.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from avalon import api
|
||||
from avalon.tvpaint import CommunicatorWrapper
|
||||
|
||||
|
||||
class ImportImage(api.Loader):
|
||||
"""Load image or image sequence to TVPaint as new layer."""
|
||||
|
||||
families = ["render", "image", "background", "plate"]
|
||||
representations = ["*"]
|
||||
|
||||
label = "Import Image"
|
||||
order = 1
|
||||
icon = "image"
|
||||
color = "white"
|
||||
|
||||
import_script = (
|
||||
"filepath = \"{}\"\n"
|
||||
"layer_name = \"{}\"\n"
|
||||
"tv_loadsequence filepath \"preload\" PARSE layer_id\n"
|
||||
"tv_layerrename layer_id layer_name"
|
||||
)
|
||||
|
||||
def load(self, context, name, namespace, options):
|
||||
# Prepare layer name
|
||||
asset_name = context["asset"]["name"]
|
||||
version_name = context["version"]["name"]
|
||||
layer_name = "{}_{}_v{:0>3}".format(
|
||||
asset_name,
|
||||
name,
|
||||
version_name
|
||||
)
|
||||
# Fill import script with filename and layer name
|
||||
# - filename mus not contain backwards slashes
|
||||
george_script = self.import_script.format(
|
||||
self.fname.replace("\\", "/"),
|
||||
layer_name
|
||||
)
|
||||
return CommunicatorWrapper.execute_george_through_file(george_script)
|
||||
Loading…
Add table
Add a link
Reference in a new issue