This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4140 from pypeclub/feature/OP-3437_CelAction-conv…
…ersion-to-op3 CelAction: refactory integration to current openpype
- Loading branch information
Showing
27 changed files
with
554 additions
and
326 deletions.
There are no files selected for viewing
This file contains 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 ( | ||
CELACTION_ROOT_DIR, | ||
CelactionAddon, | ||
) | ||
|
||
|
||
__all__ = ( | ||
"CELACTION_ROOT_DIR", | ||
"CelactionAddon", | ||
) |
This file contains 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,31 @@ | ||
import os | ||
from openpype.modules import OpenPypeModule, IHostAddon | ||
|
||
CELACTION_ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
class CelactionAddon(OpenPypeModule, IHostAddon): | ||
name = "celaction" | ||
host_name = "celaction" | ||
|
||
def initialize(self, module_settings): | ||
self.enabled = True | ||
|
||
def get_launch_hook_paths(self, app): | ||
if app.host_name != self.host_name: | ||
return [] | ||
return [ | ||
os.path.join(CELACTION_ROOT_DIR, "hooks") | ||
] | ||
|
||
def add_implementation_envs(self, env, _app): | ||
# Set default values if are not already set via settings | ||
defaults = { | ||
"LOGLEVEL": "DEBUG" | ||
} | ||
for key, value in defaults.items(): | ||
if not env.get(key): | ||
env[key] = value | ||
|
||
def get_workfile_extensions(self): | ||
return [".scn"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
122 changes: 0 additions & 122 deletions
122
openpype/hosts/celaction/hooks/pre_celaction_registers.py
This file was deleted.
Oops, something went wrong.
This file contains 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,137 @@ | ||
import os | ||
import shutil | ||
import winreg | ||
import subprocess | ||
from openpype.lib import PreLaunchHook, get_openpype_execute_args | ||
from openpype.hosts.celaction import scripts | ||
|
||
CELACTION_SCRIPTS_DIR = os.path.dirname( | ||
os.path.abspath(scripts.__file__) | ||
) | ||
|
||
|
||
class CelactionPrelaunchHook(PreLaunchHook): | ||
""" | ||
Bootstrap celacion with pype | ||
""" | ||
app_groups = ["celaction"] | ||
platforms = ["windows"] | ||
|
||
def execute(self): | ||
asset_doc = self.data["asset_doc"] | ||
width = asset_doc["data"]["resolutionWidth"] | ||
height = asset_doc["data"]["resolutionHeight"] | ||
|
||
# Add workfile path to launch arguments | ||
workfile_path = self.workfile_path() | ||
if workfile_path: | ||
self.launch_context.launch_args.append(workfile_path) | ||
|
||
# setting output parameters | ||
path_user_settings = "\\".join([ | ||
"Software", "CelAction", "CelAction2D", "User Settings" | ||
]) | ||
winreg.CreateKey(winreg.HKEY_CURRENT_USER, path_user_settings) | ||
hKey = winreg.OpenKey( | ||
winreg.HKEY_CURRENT_USER, path_user_settings, 0, | ||
winreg.KEY_ALL_ACCESS | ||
) | ||
|
||
path_to_cli = os.path.join(CELACTION_SCRIPTS_DIR, "publish_cli.py") | ||
subproces_args = get_openpype_execute_args("run", path_to_cli) | ||
openpype_executable = subproces_args.pop(0) | ||
|
||
winreg.SetValueEx( | ||
hKey, | ||
"SubmitAppTitle", | ||
0, | ||
winreg.REG_SZ, | ||
openpype_executable | ||
) | ||
|
||
parameters = subproces_args + [ | ||
"--currentFile", "*SCENE*", | ||
"--chunk", "*CHUNK*", | ||
"--frameStart", "*START*", | ||
"--frameEnd", "*END*", | ||
"--resolutionWidth", "*X*", | ||
"--resolutionHeight", "*Y*" | ||
] | ||
|
||
winreg.SetValueEx( | ||
hKey, "SubmitParametersTitle", 0, winreg.REG_SZ, | ||
subprocess.list2cmdline(parameters) | ||
) | ||
|
||
# setting resolution parameters | ||
path_submit = "\\".join([ | ||
path_user_settings, "Dialogs", "SubmitOutput" | ||
]) | ||
winreg.CreateKey(winreg.HKEY_CURRENT_USER, path_submit) | ||
hKey = winreg.OpenKey( | ||
winreg.HKEY_CURRENT_USER, path_submit, 0, | ||
winreg.KEY_ALL_ACCESS | ||
) | ||
winreg.SetValueEx(hKey, "SaveScene", 0, winreg.REG_DWORD, 1) | ||
winreg.SetValueEx(hKey, "CustomX", 0, winreg.REG_DWORD, width) | ||
winreg.SetValueEx(hKey, "CustomY", 0, winreg.REG_DWORD, height) | ||
|
||
# making sure message dialogs don't appear when overwriting | ||
path_overwrite_scene = "\\".join([ | ||
path_user_settings, "Messages", "OverwriteScene" | ||
]) | ||
winreg.CreateKey(winreg.HKEY_CURRENT_USER, path_overwrite_scene) | ||
hKey = winreg.OpenKey( | ||
winreg.HKEY_CURRENT_USER, path_overwrite_scene, 0, | ||
winreg.KEY_ALL_ACCESS | ||
) | ||
winreg.SetValueEx(hKey, "Result", 0, winreg.REG_DWORD, 6) | ||
winreg.SetValueEx(hKey, "Valid", 0, winreg.REG_DWORD, 1) | ||
|
||
# set scane as not saved | ||
path_scene_saved = "\\".join([ | ||
path_user_settings, "Messages", "SceneSaved" | ||
]) | ||
winreg.CreateKey(winreg.HKEY_CURRENT_USER, path_scene_saved) | ||
hKey = winreg.OpenKey( | ||
winreg.HKEY_CURRENT_USER, path_scene_saved, 0, | ||
winreg.KEY_ALL_ACCESS | ||
) | ||
winreg.SetValueEx(hKey, "Result", 0, winreg.REG_DWORD, 1) | ||
winreg.SetValueEx(hKey, "Valid", 0, winreg.REG_DWORD, 1) | ||
|
||
def workfile_path(self): | ||
workfile_path = self.data["last_workfile_path"] | ||
|
||
# copy workfile from template if doesnt exist any on path | ||
if not os.path.exists(workfile_path): | ||
# TODO add ability to set different template workfile path via | ||
# settings | ||
openpype_celaction_dir = os.path.dirname(CELACTION_SCRIPTS_DIR) | ||
template_path = os.path.join( | ||
openpype_celaction_dir, | ||
"resources", | ||
"celaction_template_scene.scn" | ||
) | ||
|
||
if not os.path.exists(template_path): | ||
self.log.warning( | ||
"Couldn't find workfile template file in {}".format( | ||
template_path | ||
) | ||
) | ||
return | ||
|
||
self.log.info( | ||
f"Creating workfile from template: \"{template_path}\"" | ||
) | ||
|
||
# Copy template workfile to new destinantion | ||
shutil.copy2( | ||
os.path.normpath(template_path), | ||
os.path.normpath(workfile_path) | ||
) | ||
|
||
self.log.info(f"Workfile to open: \"{workfile_path}\"") | ||
|
||
return workfile_path |
Oops, something went wrong.