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