diff --git a/src/Core/FaceInferResult.cs b/src/Core/FaceInferResult.cs
index 9176d68..63b2030 100644
--- a/src/Core/FaceInferResult.cs
+++ b/src/Core/FaceInferResult.cs
@@ -3,22 +3,15 @@ using Autodesk.Navisworks.Api;
namespace NavisworksTransport
{
///
- /// 快速取面结果。
- /// 所有坐标为宿主坐标系。
+ /// 快速取面结果。所有坐标为宿主坐标系。
///
public class FaceInferResult
{
- /// 点击命中点(宿主坐标系)
public Point3D HitPoint { get; }
-
- /// 面法向量(已归一化,朝向相机)
public Vector3D Normal { get; }
-
- /// 命中的 ModelItem
public ModelItem ModelItem { get; }
-
- /// 推断是否成功
public bool IsValid { get; }
+ public string FailureReason { get; }
public FaceInferResult(Point3D hitPoint, Vector3D normal, ModelItem modelItem)
{
@@ -26,10 +19,20 @@ namespace NavisworksTransport
Normal = normal;
ModelItem = modelItem;
IsValid = modelItem != null;
+ FailureReason = null;
}
- /// 创建失败结果
- public static FaceInferResult Invalid { get; } = new FaceInferResult(
- new Point3D(), new Vector3D(), null);
+ private FaceInferResult(string failureReason)
+ {
+ HitPoint = new Point3D();
+ Normal = new Vector3D();
+ ModelItem = null;
+ IsValid = false;
+ FailureReason = failureReason;
+ }
+
+ public static FaceInferResult Invalid { get; } = new FaceInferResult(new Point3D(), new Vector3D(), null);
+
+ public static FaceInferResult Failure(string reason) => new FaceInferResult(reason);
}
}
diff --git a/src/Core/FaceInferToolPlugin.cs b/src/Core/FaceInferToolPlugin.cs
index df3e717..96e11c5 100644
--- a/src/Core/FaceInferToolPlugin.cs
+++ b/src/Core/FaceInferToolPlugin.cs
@@ -99,7 +99,7 @@ namespace NavisworksTransport
// 拾取中心点
var centerPick = view.PickItemFromPoint(x, y);
if (centerPick == null)
- return FaceInferResult.Invalid;
+ return FaceInferResult.Failure("未命中任何模型,请点击模型表面。");
var p0 = centerPick.Point;
@@ -145,7 +145,7 @@ namespace NavisworksTransport
}
LogManager.Debug("[FaceInferTool] 所有偏移量均无法推断平面");
- return FaceInferResult.Invalid;
+ return FaceInferResult.Failure("点击位置表面过窄或不平整,无法推断平面。\n请点击较大的平整表面。");
}
// ---- Vector3D 辅助方法(避免依赖 Navisworks Vector3D 静态方法在不同版本的可用性差异)----
diff --git a/src/UI/WPF/ViewModels/PathEditingViewModel.cs b/src/UI/WPF/ViewModels/PathEditingViewModel.cs
index eab306e..215c9b5 100644
--- a/src/UI/WPF/ViewModels/PathEditingViewModel.cs
+++ b/src/UI/WPF/ViewModels/PathEditingViewModel.cs
@@ -2434,12 +2434,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
if (!result.IsValid)
{
CleanupAssemblyEndFaceSelection(clearVisuals: false);
- DialogHelper.ShowStatusAndDialog(
- "未命中有效表面。",
- "取端面失败",
- "未命中有效表面。\n请在终点箱体端面上点击。",
- UpdateMainStatus,
- System.Windows.MessageBoxImage.Warning);
+ var reason = result.FailureReason ?? "未命中有效表面。";
+ DialogHelper.ShowStatusAndDialog(reason, "取端面失败", reason, UpdateMainStatus, System.Windows.MessageBoxImage.Warning);
return;
}
@@ -2567,12 +2563,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
if (!result.IsValid)
{
CleanupAssemblyInstallationSelection();
- DialogHelper.ShowStatusAndDialog(
- "未命中有效表面。",
- "选安装面失败",
- "未命中有效表面。",
- UpdateMainStatus,
- System.Windows.MessageBoxImage.Warning);
+ var reason = result.FailureReason ?? "未命中有效表面。";
+ DialogHelper.ShowStatusAndDialog(reason, "选安装面失败", reason, UpdateMainStatus, System.Windows.MessageBoxImage.Warning);
return;
}