From a40e52f538f64a5f4a82ebce45838bbdba6f4773 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Thu, 8 Jan 2026 22:43:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8E=86=E5=8F=B2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E8=BD=BD=E5=85=A5=E5=90=8E=E8=99=9A=E6=8B=9F=E8=BD=A6?= =?UTF-8?q?=E8=BE=86=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Collision/ClashDetectiveIntegration.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Core/Collision/ClashDetectiveIntegration.cs b/src/Core/Collision/ClashDetectiveIntegration.cs index d8783a1..12f22b7 100644 --- a/src/Core/Collision/ClashDetectiveIntegration.cs +++ b/src/Core/Collision/ClashDetectiveIntegration.cs @@ -323,6 +323,12 @@ namespace NavisworksTransport testInfo.VirtualVehicleHeight ) ?? throw new InvalidOperationException($"[LoadClashDetectiveResultsFromDatabase] 创建虚拟车辆失败"); LogManager.Info($"[LoadClashDetectiveResultsFromDatabase] 已创建虚拟车辆: {testInfo.VirtualVehicleLength}×{testInfo.VirtualVehicleWidth}×{testInfo.VirtualVehicleHeight}m"); + + // 将虚拟车辆显示出来(确保不被隐藏) + var doc = Application.ActiveDocument; + var vehicleItems = new ModelItemCollection { vehicleObject }; + doc.Models.SetHidden(vehicleItems, false); + LogManager.Info($"[LoadClashDetectiveResultsFromDatabase] 虚拟车辆已显示"); } else if (testInfo.VehicleModelIndex.HasValue && !string.IsNullOrEmpty(testInfo.VehiclePathId)) { @@ -348,6 +354,32 @@ namespace NavisworksTransport throw new InvalidOperationException($"[LoadClashDetectiveResultsFromDatabase] 无法重建车辆对象: IsVirtualVehicle={testInfo.IsVirtualVehicle}, VehicleModelIndex={testInfo.VehicleModelIndex}, VehiclePathId={testInfo.VehiclePathId}"); } + // 如果是虚拟车辆,将其移动到路径起点 + if (testInfo.IsVirtualVehicle && !string.IsNullOrEmpty(testInfo.RouteId)) + { + try + { + var pathPlanningManager = PathPlanningManager.Instance; + var route = pathPlanningManager.GetAllRoutes().FirstOrDefault(r => r.Id == testInfo.RouteId); + + if (route != null && route.Points != null && route.Points.Count > 0) + { + // 获取第一个点(起点) + var startPoint = route.Points.FirstOrDefault(p => p.Type == PathPointType.StartPoint) ?? route.Points[0]; + var startPointPosition = startPoint.Position; + + // 使用 PathAnimationManager 将车辆移动到起点 + var pathAnimationManager = Core.Animation.PathAnimationManager.GetInstance(); + pathAnimationManager.SyncToPathStart(vehicleObject, new List { startPointPosition, startPointPosition }); + LogManager.Info($"[LoadClashDetectiveResultsFromDatabase] 虚拟车辆已移动到路径起点: ({startPointPosition.X:F2}, {startPointPosition.Y:F2}, {startPointPosition.Z:F2})"); + } + } + catch (Exception ex) + { + LogManager.Warning($"[LoadClashDetectiveResultsFromDatabase] 移动虚拟车辆到起点失败: {ex.Message}"); + } + } + // 3. 从数据库读取被撞物体信息 var collisionObjectsSql = @" SELECT ModelIndex, PathId, DisplayName, ObjectName