From a69d40add8b1f7468fb725f4a4909ec6884991a9 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 27 Oct 2020 17:05:14 +0100 Subject: [PATCH 1/4] tvpaint's prelaunch hook install pywin32 on windows --- pype/hooks/tvpaint/prelaunch.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pype/hooks/tvpaint/prelaunch.py b/pype/hooks/tvpaint/prelaunch.py index d616949254..0b3899f555 100644 --- a/pype/hooks/tvpaint/prelaunch.py +++ b/pype/hooks/tvpaint/prelaunch.py @@ -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"] From 270d94f29d4124dfe142ca6bd086e00b17176cf3 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 27 Oct 2020 20:58:15 +0100 Subject: [PATCH 2/4] added pype's localization file --- pype/hosts/tvpaint/__init__.py | 9 ++++++++- pype/hosts/tvpaint/avalon.loc | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 pype/hosts/tvpaint/avalon.loc diff --git a/pype/hosts/tvpaint/__init__.py b/pype/hosts/tvpaint/__init__.py index 8c93d93738..84f9cd92d5 100644 --- a/pype/hosts/tvpaint/__init__.py +++ b/pype/hosts/tvpaint/__init__.py @@ -1 +1,8 @@ -kwargs = None +import os +from avalon.tvpaint.communication_server import register_localization_file + + +def install(): + current_dir = os.path.dirname(os.path.abspath(__file__)) + localization_file = os.path.join(current_dir, "avalon.loc") + register_localization_file(localization_file) diff --git a/pype/hosts/tvpaint/avalon.loc b/pype/hosts/tvpaint/avalon.loc new file mode 100644 index 0000000000..cda27162e6 --- /dev/null +++ b/pype/hosts/tvpaint/avalon.loc @@ -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 -------------------------------- +#------------------------------------------------- From 5ebe474b1c9026a329b0036cedbd82ef7d101dd0 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 11:42:09 +0100 Subject: [PATCH 3/4] install tvpaint register plugins --- pype/hosts/tvpaint/__init__.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pype/hosts/tvpaint/__init__.py b/pype/hosts/tvpaint/__init__.py index 84f9cd92d5..cb02c87151 100644 --- a/pype/hosts/tvpaint/__init__.py +++ b/pype/hosts/tvpaint/__init__.py @@ -1,8 +1,31 @@ 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) From 0ad60ef853c9ccf30bee9d58901963e9111d8c9f Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 16:43:42 +0100 Subject: [PATCH 4/4] implemented simple image loader --- pype/plugins/tvpaint/load/load_image.py | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pype/plugins/tvpaint/load/load_image.py diff --git a/pype/plugins/tvpaint/load/load_image.py b/pype/plugins/tvpaint/load/load_image.py new file mode 100644 index 0000000000..ec126adbee --- /dev/null +++ b/pype/plugins/tvpaint/load/load_image.py @@ -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)