From 3884d0571741edc5767f00079df5e484d69d4975 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Fri, 7 Aug 2026 09:45:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=A7=E6=A8=A1=E5=9E=8B=E8=AF=84?= =?UTF-8?q?=E4=BC=B0=E5=BC=95=E5=AF=BC=E6=89=B9=E5=A4=84=E7=90=86=EF=BC=88?= =?UTF-8?q?=E9=9D=9E=E6=89=8B=E5=B7=A5=E6=8C=87=E5=AE=9A=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=8A=A8=E7=94=BB=E5=85=A5=E5=8F=A3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 背景:交互模式 + 非手工指定 + 大型模型 → 主 NW 全模型检测小时级; 剖面盒导出(F1 副实例)已解决耗时问题——生成动画入口增加评估环节。 改动: - BatchConfig.LargeModelFileSizeMb(默认 50 MB,config.toml [batch] large_model_file_size_mb 可调) - ExecuteGenerateAnimation 入口:非手工指定模式 + 模型文件大小 ≥ 阈值 → 弹窗引导:'是' = 加入批处理队列(提示到批处理页签启动)、 '否' = 继续当前进程检测;小模型静默继续(O(1) 评估零延迟) - TryGetCurrentModelFileSizeMb:文档文件大小(MB) 阈值思路:NWD 文件大小与几何对象数强相关,O(1) 获取; 不做对象数枚举(大模型枚举 10+ 秒违背评估目的) 验证:集成测试 25/25 --- resources/default_config.toml | 5 ++ src/Core/Config/SystemConfig.cs | 6 ++ .../ViewModels/AnimationControlViewModel.cs | 62 +++++++++++++++++++ 3 files changed, 73 insertions(+) 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; + } + } + /// /// 添加到批处理队列 ///