Skip to content

Commit e4ff24e

Browse files
committed
wip: fix for Alias 2027.1 python api (need to revisit)
1 parent e4d09e3 commit e4ff24e

4 files changed

Lines changed: 43 additions & 67 deletions

File tree

plugins/FlowToolkitAliasPlugin.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,22 @@
2222

2323

2424
@alpy.plugin(
25-
name="Flow Toolkit",
26-
description="Flow Production Tracking integration for Alias",
25+
name="Flow PT for Alias",
26+
description="Flow Production Tracking Toolkit integration for Alias",
2727
author="Autodesk",
2828
version="0.1",
2929
)
3030
class FlowToolkitAliasPlugin:
31-
"""Register the Flow Toolkit plugin with Alias."""
31+
"""Register the Flow Production Tracking Toolkit plugin with Alias."""
3232

3333

34-
@alpy.continuous_tool(menu=alpy.palette.PICK)
34+
@alpy.momentary_tool(keep_active_tool=True, attribute_string="fptalias")
3535
class FlowToolkitTool:
3636
"""Placeholder tool required by Alias plugin parser."""
3737

38-
@alpy.tool_init(
39-
manipulates_pick_list=False, coordinate_type=alpy.COORDINATE_ABSOLUTE
40-
)
41-
def on_tool_begin(self):
42-
pass
43-
44-
@alpy.tool_cleanup
45-
def on_tool_end(self):
46-
pass
38+
@alpy.on_activate
39+
def on_activate(self) -> None:
40+
alpy.log_to_prompt("Flow Production Tracking Toolkit for Alias activated")
4741

4842

4943
@alpy.plugin_init

plugins/temp/flow_toolkit.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

python/tk_alias/menu_generation.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,34 @@
1414
from sgtk.util import is_windows, is_macos, is_linux
1515

1616

17+
class _AliasMenuCompat:
18+
"""Compatibility wrapper for Alias 2027+ menu API.
19+
20+
Provides the same interface as the old Menu class (add_menu, add_command,
21+
clean, remove) but routes calls to the new standalone API functions.
22+
The new API uses string-based parent references instead of object handles.
23+
"""
24+
25+
def __init__(self, alias_py, name):
26+
self._alias_py = alias_py
27+
self._name = name
28+
29+
def add_menu(self, text):
30+
self._alias_py._alpy_make_submenu(self._name, text)
31+
return text
32+
33+
def add_command(self, name, callback, parent=None, add_separator=False):
34+
parent_name = parent if isinstance(parent, str) else self._name
35+
on_submenu = parent is not None
36+
self._alias_py._alpy_make_menu_item(name, parent_name, on_submenu, callback)
37+
38+
def clean(self):
39+
return None
40+
41+
def remove(self):
42+
return None
43+
44+
1745
class AliasMenuGenerator(object):
1846
"""Menu handling for Alias."""
1947

@@ -65,7 +93,13 @@ def build(self):
6593

6694
if self.alias_menu is None:
6795
# First, create the Flow Production Tracking menu in Alias.
68-
self.__alias_menu = self.engine.alias_py.Menu(self.menu_name)
96+
if hasattr(self.engine.alias_py, "Menu"):
97+
self.__alias_menu = self.engine.alias_py.Menu(self.menu_name)
98+
else:
99+
self.engine.alias_py._alpy_make_main_menu(self.menu_name)
100+
self.__alias_menu = _AliasMenuCompat(
101+
self.engine.alias_py, self.menu_name
102+
)
69103
else:
70104
# Make sure we're starting with a fresh menu
71105
self.clean_menu()

startup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ def prepare_launch(self, exec_path, args, file_to_open=None):
150150
required_env["ALIAS_INTERNAL_PYTHON_SCRIPT_FOLDER"] = os.path.join(
151151
self.disk_location, "plugins"
152152
)
153-
# FIXME default to 0
154-
alias_debug = os.environ.get("TK_ALIAS_DEBUG_CONSOLE", "1")
155-
required_env["ALIAS_DEBUG_CONSOLE"] = alias_debug
153+
required_env["ALIAS_DEBUG_CONSOLE"] = os.environ.get("TK_DEBUG", "0")
156154

157155
# Get the launch app path and args
158156
app_path, app_args = self.__prepare_launch_args(

0 commit comments

Comments
 (0)