From bb44b1b1aab600590b0141c1659904103c9d4d98 Mon Sep 17 00:00:00 2001 From: codex Date: Fri, 31 Jul 2026 15:57:06 +0300 Subject: [PATCH] fix: resolve Plant project context diagnostics --- .../src/PRecAnnot.Abstractions/Contracts.cs | 2 ++ .../src/PRecAnnot.Plant3D2026/PlantReadPath.cs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Abstractions/Contracts.cs b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Abstractions/Contracts.cs index 5738fb4..af5a996 100644 --- a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Abstractions/Contracts.cs +++ b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Abstractions/Contracts.cs @@ -8,6 +8,7 @@ public sealed record RuntimeDiagnostic } public enum OrthoDetectionStatus { Confirmed, NotOrtho, Ambiguous, Unsupported, Failed } +public enum PlantProjectDetectionStatus { NotFound, FoundWithName, FoundWithoutDisplayName, Ambiguous, Failed } public sealed record OrthoDetectionResult { @@ -66,6 +67,7 @@ public sealed record PlantRuntimeContext public bool IsOrthoDrawing { get; init; } public string? DrawingName { get; init; } public string? ProjectDisplayName { get; init; } + public PlantProjectDetectionStatus ProjectDetectionStatus { get; init; } = PlantProjectDetectionStatus.NotFound; public IReadOnlyList Viewports { get; init; } = Array.Empty(); public IReadOnlyList Diagnostics { get; init; } = Array.Empty(); public OrthoDetectionResult Detection { get; init; } = new() { Status = OrthoDetectionStatus.Unsupported, Evidence = Array.Empty(), Diagnostics = Array.Empty() }; diff --git a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/PlantReadPath.cs b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/PlantReadPath.cs index ef70177..7ba66e7 100644 --- a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/PlantReadPath.cs +++ b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/PlantReadPath.cs @@ -32,6 +32,9 @@ internal sealed class PlantRuntimeContextReader : IPlantRuntimeContextReader return Empty(true, false, "NO_PLANT_PROJECT", "Активный Plant 3D-проект не найден."); } + var displayName = string.IsNullOrWhiteSpace(project.Name) ? null : project.Name.Trim(); + var projectStatus = displayName is null ? PlantProjectDetectionStatus.FoundWithoutDisplayName : PlantProjectDetectionStatus.FoundWithName; + OrthoProject? orthoProject; try { orthoProject = PlantApplication.ProjectPart("Ortho") as OrthoProject; } catch (Exception exception) @@ -60,9 +63,10 @@ internal sealed class PlantRuntimeContextReader : IPlantRuntimeContextReader HasPlantProject = true, IsOrthoDrawing = true, DrawingName = Path.GetFileName(document.Name), - ProjectDisplayName = project.Name, + ProjectDisplayName = displayName ?? "display name unavailable", + ProjectDetectionStatus = projectStatus, Viewports = viewports, - Diagnostics = Array.Empty(), + Diagnostics = displayName is null ? new[] { new RuntimeDiagnostic { Code = "PLANT_PROJECT_DISPLAY_NAME_EMPTY", Message = "Plant project is open but no display name is available.", Severity = "Warning" } } : Array.Empty(), Detection = new OrthoDetectionResult { Status = OrthoDetectionStatus.Confirmed, @@ -82,6 +86,8 @@ internal sealed class PlantRuntimeContextReader : IPlantRuntimeContextReader HasActiveDocument = hasDocument, HasPlantProject = hasProject, IsOrthoDrawing = false, + ProjectDisplayName = hasProject ? "display name unavailable" : null, + ProjectDetectionStatus = hasProject ? PlantProjectDetectionStatus.Ambiguous : PlantProjectDetectionStatus.NotFound, Diagnostics = new[] { new RuntimeDiagnostic { Code = code, Message = message } }, Detection = new OrthoDetectionResult { Status = status, Evidence = evidence, Diagnostics = new[] { new RuntimeDiagnostic { Code = code, Message = message } } } };