From 4acd7e48469cb49b34c7dee818694a43a45a91a8 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Wed, 5 Aug 2026 17:39:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20F1=20=E5=AF=BC=E5=87=BA=E5=89=8D?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E7=A7=BB=E5=8A=A8=E7=89=A9=E4=BD=93=E5=88=B0?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E8=B5=B7=E7=82=B9=EF=BC=88=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=8C=85=E5=90=AB=EF=BC=8C=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E7=9B=92=E5=A4=96=E7=89=A9=E4=BD=93=E5=A4=B1=E8=B4=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 加入批处理时物体移到起点,但后续操作会将其移回 CAD 原位置(甚至不在路径剖面盒内) - F1 导出前:按批处理项记录的 MovingObject PathId 解析移动物体 → MoveObjectToPathStart 恢复到路径起点 → 再导出 - 验证:96"(CAD 位置 Z=-35 盒外)现可正常检测(碰撞 17,此前'无法解析真实物体'失败) --- src/Core/BatchQueueManager.cs | 6 ++++ src/Core/Services/SectionBoxBatchDetector.cs | 35 ++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/Core/BatchQueueManager.cs b/src/Core/BatchQueueManager.cs index 91fedf7..3be3db9 100644 --- a/src/Core/BatchQueueManager.cs +++ b/src/Core/BatchQueueManager.cs @@ -527,6 +527,8 @@ namespace NavisworksTransport.Core // 真实物体名从 ModelItemReferences(Role=MovingObject)读取(BatchQueueItems 表无此列) string movingObjectName = item.MovingObjectName; string expectedAncestorChain = null; + int movingModelIndex = 0; + string movingObjectPathId = null; if (!item.IsVirtualObject) { var movingRefs = await _database.GetModelItemReferencesAsync( @@ -534,6 +536,8 @@ namespace NavisworksTransport.Core if (movingRefs.Count > 0) { movingObjectName = movingRefs[0].ObjectName ?? movingRefs[0].DisplayName; + movingModelIndex = movingRefs[0].ModelIndex; + movingObjectPathId = movingRefs[0].PathId; // 主 NW 按 PathId 解析移动物体 → 层级链(导出剖面盒保留树结构,副实例按链匹配) try @@ -570,6 +574,8 @@ namespace NavisworksTransport.Core item.IsVirtualObject, movingObjectName, expectedAncestorChain, + movingModelIndex, + movingObjectPathId, item.VirtualObjectLength, item.VirtualObjectWidth, item.VirtualObjectHeight, diff --git a/src/Core/Services/SectionBoxBatchDetector.cs b/src/Core/Services/SectionBoxBatchDetector.cs index 29ba78a..8289071 100644 --- a/src/Core/Services/SectionBoxBatchDetector.cs +++ b/src/Core/Services/SectionBoxBatchDetector.cs @@ -86,6 +86,8 @@ namespace NavisworksTransport.Core.Services bool isVirtualObject, string movingObjectName, string expectedAncestorChain, + int movingModelIndex, + string movingObjectPathId, double virtualObjectLengthModelUnits, double virtualObjectWidthModelUnits, double virtualObjectHeightModelUnits, @@ -135,6 +137,39 @@ namespace NavisworksTransport.Core.Services { exported = System.Windows.Application.Current.Dispatcher.Invoke(() => { + // 导出前:把移动物体恢复到路径起点(加入批处理时的位置),确保导出包含移动物体。 + // 真实物体可能已被后续操作移回 CAD 原位置(甚至不在路径剖面盒内)。 + if (!isVirtualObject && !string.IsNullOrWhiteSpace(movingObjectPathId)) + { + try + { + var pathAnim = Core.Animation.PathAnimationManager.GetInstance(); + if (pathAnim != null && route != null) + { + pathAnim.SetRoute(route); + var movingItem = document.Models.ResolvePathId(new Autodesk.Navisworks.Api.DocumentParts.ModelItemPathId + { + ModelIndex = movingModelIndex, + PathId = movingObjectPathId + }); + if (movingItem != null) + { + pathAnim.MoveObjectToPathStart( + movingItem, route.Points.Select(p => p.Position).ToList()); + LogManager.Info($"[剖面盒批检测] 移动物体已恢复到路径起点: {movingItem.DisplayName}"); + } + else + { + LogManager.Warning($"[剖面盒批检测] 无法解析移动物体 ModelItem({movingObjectPathId}),导出可能不包含该物体"); + } + } + } + catch (Exception moveEx) + { + LogManager.Warning($"[剖面盒批检测] 移动物体恢复到起点失败: {moveEx.Message}"); + } + } + var exporter = new SectionBoxExporter(); var traversal = exporter.GetObjectsAndHiddenItems(document, bounds); if (traversal.ObjectsInBox.Count == 0)