From d2f94c3d78976aa63882f5e7e25eca8177302b74 Mon Sep 17 00:00:00 2001 From: forbes Date: Sun, 1 Feb 2026 19:51:56 -0600 Subject: [PATCH] fix: defer PartDesign manipulator registration until commands are imported The _ZToolsPartDesignManipulator was registered at module load time via Gui.addWorkbenchManipulator(), but the commands it references (ZTools_DatumCreator, ZTools_DatumManager, ZTools_EnhancedPocket, ZTools_RotatedLinearPattern) are not registered until Initialize() imports the command modules. Move the addWorkbenchManipulator() call into Initialize() with a guard to prevent duplicate registration. This eliminates the 'Unknown command' warnings on startup. --- ztools/InitGui.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ztools/InitGui.py b/ztools/InitGui.py index c04cdcb..2f1fd52 100644 --- a/ztools/InitGui.py +++ b/ztools/InitGui.py @@ -306,6 +306,12 @@ class ZToolsWorkbench(Gui.Workbench): + self.ztools_spreadsheet_tools, ) + # Register the PartDesign manipulator now that commands exist. + # Guard so it only registers once even if Initialize is called again. + if not getattr(ZToolsWorkbench, "_manipulator_installed", False): + ZToolsWorkbench._manipulator_installed = True + Gui.addWorkbenchManipulator(_ZToolsPartDesignManipulator()) + App.Console.PrintMessage("ztools workbench initialized\n") def Activated(self): @@ -334,6 +340,8 @@ Gui.addWorkbench(ZToolsWorkbench()) # --------------------------------------------------------------------------- # WorkbenchManipulator: inject ZTools commands into PartDesign workbench # --------------------------------------------------------------------------- +# Registered in ZToolsWorkbench.Initialize() after commands are imported, +# so the commands exist before the manipulator references them. class _ZToolsPartDesignManipulator: @@ -376,6 +384,3 @@ class _ZToolsPartDesignManipulator: "after": "", }, ] - - -Gui.addWorkbenchManipulator(_ZToolsPartDesignManipulator())