diff --git a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs
index ec47b88..b31533f 100644
--- a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs
+++ b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs
@@ -619,7 +619,12 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 注意:只有路径真正改变时才移动(避免初始设置null时的不必要移动)
if (value != null && oldRoute != value)
{
+ // 保留 lift(物体姿态不变,离地高度保持不变)。
+ // 保留 _autoAabbSx 缓存(物理尺寸与路径方向无关)。
+ // 保留 _objectRotationCorrection(物体姿态不变)。
MoveAnimatedObjectToPathStart();
+ // 用现有缓存刷新路径可视化和通行空间,不走 CalculateRotatedDimensions
+ UpdatePassageSpaceVisualization();
}
}
}
@@ -2224,6 +2229,11 @@ namespace NavisworksTransport.UI.WPF.ViewModels
{
_pathAnimationManager?.ApplyObjectStartPlacementRequest(placementRequest);
ObjectRotationCorrection = placementRequest.RotationCorrection;
+ // 手动改角度后实测AABB缓存,与自动调整/贴地一致
+ var manualAdapter = CoordinateSystemManager.Instance.CreateHostAdapter();
+ var manualDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;
+ var manualItems = new ModelItemCollection { SelectedAnimatedObject };
+ MeasureXAlignedAabbAndSetCache(SelectedAnimatedObject, manualItems, manualAdapter, manualDoc);
}
if (isAutoAdjusted)
{
@@ -5128,6 +5138,23 @@ namespace NavisworksTransport.UI.WPF.ViewModels
return result;
}
+ ///
+ /// 暴露实测 AABB 缓存给外部(如 PathEditingViewModel 的物体参数同步),
+ /// 避免它们走 correction 投影导致失真。
+ ///
+ public bool TryGetCachedAabbSizes(out double forward, out double side, out double up)
+ {
+ if (_autoAabbSx.HasValue)
+ {
+ forward = _autoAabbSx.Value;
+ side = _autoAabbSz.Value;
+ up = _autoAabbSy.Value;
+ return true;
+ }
+ forward = side = up = 0;
+ return false;
+ }
+
///
/// 根据路径类型更新通行空间可视化
/// 空轨和吊装路径默认打开通行空间(物体通行空间模式),地面路径不打开
diff --git a/src/UI/WPF/ViewModels/PathEditingViewModel.cs b/src/UI/WPF/ViewModels/PathEditingViewModel.cs
index 09aa62a..8e7fe0d 100644
--- a/src/UI/WPF/ViewModels/PathEditingViewModel.cs
+++ b/src/UI/WPF/ViewModels/PathEditingViewModel.cs
@@ -6364,48 +6364,64 @@ namespace NavisworksTransport.UI.WPF.ViewModels
}
else if (animationVm.SelectedAnimatedObject != null)
{
- var animationManager = NavisworksTransport.Core.Animation.PathAnimationManager.GetInstance();
- if ((pathType == PathType.Ground || pathType == PathType.Hoisting) &&
- animationManager != null &&
- animationManager.TryGetCurrentRouteRealObjectPlanarProjectedExtents(
- out double resolvedPlanarForward,
- out double resolvedPlanarSide,
- out double resolvedPlanarUp))
+ // 优先使用 AnimationControlViewModel 的实测 AABB 缓存
+ // (贴合地面/自动调整后设置),避免 correction 投影失真
+ if (animationVm.TryGetCachedAabbSizes(out double cachedFwd, out double cachedSide, out double cachedUp))
{
- objectLengthModel = resolvedPlanarForward;
- objectWidthModel = resolvedPlanarSide;
- objectHeightModel = resolvedPlanarUp;
+ objectLengthModel = cachedFwd;
+ objectWidthModel = cachedSide;
+ objectHeightModel = cachedUp;
LogManager.Debug(
- $"[物体参数同步] 使用真实物体平面路径最终姿态尺寸: " +
- $"沿路径={resolvedPlanarForward / metersToUnits:F2}m, " +
- $"垂直路径={resolvedPlanarSide / metersToUnits:F2}m, " +
- $"法线={resolvedPlanarUp / metersToUnits:F2}m");
- }
- else if (pathType == PathType.Rail &&
- animationManager != null &&
- animationManager.TryGetCurrentRouteRealObjectRailProjectedExtents(
- out double resolvedRailForward,
- out double resolvedRailSide,
- out double resolvedRailUp))
- {
- objectLengthModel = resolvedRailForward;
- objectWidthModel = resolvedRailSide;
- objectHeightModel = resolvedRailUp;
- LogManager.Debug(
- $"[物体参数同步] 使用真实物体 Rail 最终姿态尺寸: " +
- $"沿路径={resolvedRailForward / metersToUnits:F2}m, " +
- $"垂直路径={resolvedRailSide / metersToUnits:F2}m, " +
- $"法线={resolvedRailUp / metersToUnits:F2}m");
+ $"[物体参数同步] 复用贴合地面/自动调整实测AABB: " +
+ $"沿路径={cachedFwd / metersToUnits:F2}m, " +
+ $"垂直路径={cachedSide / metersToUnits:F2}m, " +
+ $"法线={cachedUp / metersToUnits:F2}m");
}
else
{
- // 回退:使用选择物体时保存的原始尺寸(米)
- objectLengthModel = animationVm.ObjectOriginalLength * metersToUnits;
- objectWidthModel = animationVm.ObjectOriginalWidth * metersToUnits;
- objectHeightModel = animationVm.ObjectOriginalHeight * metersToUnits;
- LogManager.Debug(
- $"[物体参数同步] 回退使用选择物体保存的原始尺寸: " +
- $"{animationVm.ObjectOriginalLength:F2}m x {animationVm.ObjectOriginalWidth:F2}m x {animationVm.ObjectOriginalHeight:F2}m");
+ var animationManager = NavisworksTransport.Core.Animation.PathAnimationManager.GetInstance();
+ if ((pathType == PathType.Ground || pathType == PathType.Hoisting) &&
+ animationManager != null &&
+ animationManager.TryGetCurrentRouteRealObjectPlanarProjectedExtents(
+ out double resolvedPlanarForward,
+ out double resolvedPlanarSide,
+ out double resolvedPlanarUp))
+ {
+ objectLengthModel = resolvedPlanarForward;
+ objectWidthModel = resolvedPlanarSide;
+ objectHeightModel = resolvedPlanarUp;
+ LogManager.Debug(
+ $"[物体参数同步] 使用真实物体平面路径最终姿态尺寸: " +
+ $"沿路径={resolvedPlanarForward / metersToUnits:F2}m, " +
+ $"垂直路径={resolvedPlanarSide / metersToUnits:F2}m, " +
+ $"法线={resolvedPlanarUp / metersToUnits:F2}m");
+ }
+ else if (pathType == PathType.Rail &&
+ animationManager != null &&
+ animationManager.TryGetCurrentRouteRealObjectRailProjectedExtents(
+ out double resolvedRailForward,
+ out double resolvedRailSide,
+ out double resolvedRailUp))
+ {
+ objectLengthModel = resolvedRailForward;
+ objectWidthModel = resolvedRailSide;
+ objectHeightModel = resolvedRailUp;
+ LogManager.Debug(
+ $"[物体参数同步] 使用真实物体 Rail 最终姿态尺寸: " +
+ $"沿路径={resolvedRailForward / metersToUnits:F2}m, " +
+ $"垂直路径={resolvedRailSide / metersToUnits:F2}m, " +
+ $"法线={resolvedRailUp / metersToUnits:F2}m");
+ }
+ else
+ {
+ // 回退:使用选择物体时保存的原始尺寸(米)
+ objectLengthModel = animationVm.ObjectOriginalLength * metersToUnits;
+ objectWidthModel = animationVm.ObjectOriginalWidth * metersToUnits;
+ objectHeightModel = animationVm.ObjectOriginalHeight * metersToUnits;
+ LogManager.Debug(
+ $"[物体参数同步] 回退使用选择物体保存的原始尺寸: " +
+ $"{animationVm.ObjectOriginalLength:F2}m x {animationVm.ObjectOriginalWidth:F2}m x {animationVm.ObjectOriginalHeight:F2}m");
+ }
}
}
else