diff --git a/src/Core/PathInputMonitor.cs b/src/Core/PathInputMonitor.cs index 57a5525..04e119e 100644 --- a/src/Core/PathInputMonitor.cs +++ b/src/Core/PathInputMonitor.cs @@ -49,7 +49,7 @@ namespace NavisworksTransport if (currentTool != Tool.CustomToolPlugin) { LogManager.Info($"[InputMonitor] 用户按空格键,当前工具为{currentTool},强制恢复ToolPlugin焦点"); - bool restored = pathManager.ForceReinitializeToolPlugin(subscribeToEvents: false); + bool restored = pathManager.RestoreToolPluginFocusForCurrentContext(); if (restored) { return true; diff --git a/src/Core/PathPlanningManager.cs b/src/Core/PathPlanningManager.cs index 94b5455..620187b 100644 --- a/src/Core/PathPlanningManager.cs +++ b/src/Core/PathPlanningManager.cs @@ -4562,6 +4562,33 @@ namespace NavisworksTransport } } + /// + /// 根据当前业务上下文恢复 ToolPlugin 焦点。 + /// 普通手动建/编辑路径应恢复 PathPlanningManager 主链; + /// 自动路径、装配拾取、多层吊装等外部自管拾取模式则保持外部事件处理。 + /// + public bool RestoreToolPluginFocusForCurrentContext() + { + try + { + bool shouldSubscribeToManagerEvents = !IsInAutoPathMode; + string contextLabel = shouldSubscribeToManagerEvents + ? "普通手动取点" + : "外部自管拾取"; + + LogManager.Info( + $"[工具插件恢复] 按当前上下文恢复焦点: 模式={contextLabel}, " + + $"PathEditState={PathEditState}, 订阅PathPlanningManager事件={shouldSubscribeToManagerEvents}"); + + return ForceReinitializeToolPlugin(shouldSubscribeToManagerEvents); + } + catch (Exception ex) + { + LogManager.Error($"[工具插件恢复] 按当前上下文恢复焦点失败: {ex.Message}", ex); + return false; + } + } + #endregion #region 路径计算和保存