Merge pull request #216 from BigRoy/enhancement/fusion_launch_with_menu

Fusion: Add Launch Hook to start "AYON menu" on Fusion start
This commit is contained in:
Petr Kalis 2024-04-05 13:08:27 +02:00 committed by GitHub
commit 3457dc7e44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,36 @@
import os
from ayon_core.lib import PreLaunchHook
from ayon_core.hosts.fusion import FUSION_HOST_DIR
class FusionLaunchMenuHook(PreLaunchHook):
"""Launch AYON menu on start of Fusion"""
app_groups = ["fusion"]
order = 9
def execute(self):
# Prelaunch hook is optional
settings = self.data["project_settings"][self.host_name]
if not settings["hooks"]["FusionLaunchMenuHook"]["enabled"]:
return
variant = self.application.name
if variant.isnumeric():
version = int(variant)
if version < 18:
print("Skipping launch of OpenPype menu on Fusion start "
"because Fusion version below 18.0 does not support "
"/execute argument on launch. "
f"Version detected: {version}")
return
else:
print(f"Application variant is not numeric: {variant}. "
"Validation for Fusion version 18+ for /execute "
"prelaunch argument skipped.")
path = os.path.join(FUSION_HOST_DIR,
"deploy",
"MenuScripts",
"launch_menu.py").replace("\\", "/")
script = f"fusion:RunScript('{path}')"
self.launch_context.launch_args.extend(["/execute", script])

View file

@ -75,6 +75,12 @@ class HooksModel(BaseSettingsModel):
default_factory=HookOptionalModel,
title="Install PySide2"
)
FusionLaunchMenuHook: HookOptionalModel = SettingsField(
default_factory=HookOptionalModel,
title="Launch AYON Menu on Fusion Start",
description="Launch the AYON menu on Fusion application startup. "
"This is only supported for Fusion 18+"
)
class CreateSaverModel(CreateSaverPluginModel):
@ -143,6 +149,9 @@ DEFAULT_VALUES = {
"hooks": {
"InstallPySideToFusion": {
"enabled": True
},
"FusionLaunchMenuHook": {
"enabled": False
}
},
"create": {

View file

@ -1 +1 @@
__version__ = "0.1.4"
__version__ = "0.1.5"