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.
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user