diff --git a/resources/default_config.toml b/resources/default_config.toml index 589eb86..9ee0afa 100644 --- a/resources/default_config.toml +++ b/resources/default_config.toml @@ -98,6 +98,11 @@ width_limit_meters = 3.0 # 并发副 Navisworks 实例数(范围 1-20,默认 3) # 每个实例独立端口(18778 起)与日志,用于剖面盒自动检测等任务加速 max_parallel_instances = 3 + + # 大模型阈值(MB):非手工指定模式点击“生成动画”时, + # 模型文件超过该大小则引导使用批处理(剖面盒副实例检测,显著加速) + # 小模型静默继续当前检测;可调:小模型误判调大,大模型漏判调小 + large_model_file_size_mb = 50.0 # 自定义物流类别 # 用于扩展内置类别,只需填写类别名称 diff --git a/src/Core/Config/SystemConfig.cs b/src/Core/Config/SystemConfig.cs index 8a360ff..9647976 100644 --- a/src/Core/Config/SystemConfig.cs +++ b/src/Core/Config/SystemConfig.cs @@ -346,5 +346,11 @@ namespace NavisworksTransport.Core.Config /// 并发副 Navisworks 实例数(默认 3,范围 1-20) /// public int MaxParallelInstances { get; set; } = 3; + + /// + /// 大模型阈值(MB):非手工指定模式点击“生成动画”时, + /// 模型文件超过该大小则引导使用批处理(剖面盒副实例检测) + /// + public double LargeModelFileSizeMb { get; set; } = 50.0; } } diff --git a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs index 5163420..517c0fa 100644 --- a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs +++ b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs @@ -4873,6 +4873,39 @@ namespace NavisworksTransport.UI.WPF.ViewModels return; } + // 🔥 大模型评估(非手工指定模式):全模型检测在大型模型上耗时长(小时级), + // 引导使用批处理(剖面盒副实例检测)。文件大小 O(1) 评估,零延迟。 + if (!IsManualCollisionTargetEnabled && TryGetCurrentModelFileSizeMb(out double modelFileSizeMb)) + { + double largeModelThresholdMb = ConfigManager.Instance.Current?.Batch?.LargeModelFileSizeMb ?? 50.0; + if (modelFileSizeMb >= largeModelThresholdMb) + { + LogManager.Info($"[大模型评估] 模型 {modelFileSizeMb:F0} MB >= 阈值 {largeModelThresholdMb:F0} MB,引导使用批处理"); + var confirm = System.Windows.MessageBox.Show( + $"检测到大型模型({modelFileSizeMb:F0} MB)。非手工指定模式的全模型碰撞检测预计耗时很长。\n\n" + + $"• 是:加入批处理队列(推荐——使用剖面盒副实例检测,显著加速,检测结果完整落库)\n" + + $"• 否:继续在当前进程检测(耗时可能很长)\n\n" + + $"(阈值可在 config.toml [batch] large_model_file_size_mb 调整,当前 {largeModelThresholdMb:F0} MB)", + "大型模型检测建议", + System.Windows.MessageBoxButton.YesNo, + System.Windows.MessageBoxImage.Warning); + + if (confirm == System.Windows.MessageBoxResult.Yes) + { + Mouse.OverrideCursor = oldCursor; + ExecuteAddToBatchQueue(); + System.Windows.MessageBox.Show( + "已将当前配置加入批处理队列,请到批处理页签启动执行。", + "已加入批处理", + System.Windows.MessageBoxButton.OK, + System.Windows.MessageBoxImage.Information); + return; + } + + LogManager.Info("[大模型评估] 用户选择继续在当前进程检测"); + } + } + // 设置等待光标 Mouse.OverrideCursor = Cursors.Wait; @@ -6014,6 +6047,35 @@ namespace NavisworksTransport.UI.WPF.ViewModels return results; } + /// + /// 获取当前模型文件大小(MB)。O(1) 评估——大模型引导批处理用。 + /// + private static bool TryGetCurrentModelFileSizeMb(out double fileSizeMb) + { + fileSizeMb = 0.0; + try + { + var doc = Autodesk.Navisworks.Api.Application.ActiveDocument; + if (doc == null || doc.IsClear || string.IsNullOrWhiteSpace(doc.FileName)) + { + return false; + } + + var fileInfo = new System.IO.FileInfo(doc.FileName); + if (!fileInfo.Exists) + { + return false; + } + + fileSizeMb = fileInfo.Length / (1024.0 * 1024.0); + return true; + } + catch + { + return false; + } + } + /// /// 添加到批处理队列 ///