Hey - I managed to get it functional last week, or at least I thought I had.
It was broken again today and I have finally managed to get it functioning properly.
This is the updated create_zmenu_script.py
:
"""Pre-launch to force zbrush startup script."""
import os
from ayon_applications import PreLaunchHook, LaunchTypes
from ayon_core.lib import get_ayon_launcher_args
from ayon_zbrush import ZBRUSH_HOST_DIR
class CreateZMenuScript(PreLaunchHook):
"""Create AYON Menu Zscript to Zbrush.
Note that this works in combination whit Zbrush startup script
to successfully install zscripts.menu
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups = {"zbrush"}
order = 12
launch_types = {LaunchTypes.local}
def execute(self):
zscript_path = os.path.join(ZBRUSH_HOST_DIR, "api", "zscripts")
os.makedirs(zscript_path, exist_ok=True)
zscript_txt = os.path.join(zscript_path, "ayon_zbrush_menu.txt")
with open(zscript_txt, "w") as zscript:
zscript.write(self.ayon_menu())
zscript.close()
def ayon_menu(self):
launch_command_list = get_ayon_launcher_args(
"addon", "zbrush", "run-with-zscript", "--launcher"
)
launch_command = (
'", #quote]]\n\t[VarSet, cmd, [StrMerge, cmd, " ", #quote, "'.join(
launch_command_list
)
)
launch_command = (
'[VarSet, cmd, [StrMerge, "call", " ", #quote, "'
+ launch_command
+ '", #quote]]'
)
ayon_script = (
"""
// Set a variable to " so we can quote the command line arguments for ShellExecute
[VarSet, quote, [StrFromAsc, 34]]
[IPalette, "AYON", 1]
[ISubPalette, "AYON:Tools", 2]
// Load
[IButton, "AYON:Tools:Load...", "Open AYON Loader",
{launch_command}
[VarSet, cmd, [StrMerge, cmd, " ", #quote, "loader_tool", #quote]]
[ShellExecute, cmd], 0, 120
]
// Publish
[IButton, "AYON:Tools:Publish...", "Open AYON Publisher",
{launch_command}
[VarSet, cmd, [StrMerge, cmd, " ", #quote, "publish_tool", #quote]]
[ShellExecute, cmd], 0, 120
]
// Manage
[IButton, "AYON:Tools:Manage...", "Open AYON Scene Inventory UI",
{launch_command}
[VarSet, cmd, [StrMerge, cmd, " ", #quote, "scene_inventory_tool", #quote]]
[ShellExecute, cmd], 0, 120
]
[ISubPalette, "AYON:Project", 2]
// Workfile
[IButton, "AYON:Project:Work Files...", "Open AYON Work Files UI",
{launch_command}
[VarSet, cmd, [StrMerge, cmd, " ", #quote, "workfiles_tool", #quote]]
[ShellExecute, cmd], 0, 120
]"""
).format(launch_command=launch_command)
return ayon_script
Major difference is changing the start
command to call
- this might be a windows only thing though?