fix: resolve Plant project context diagnostics

This commit is contained in:
codex
2026-07-31 15:57:06 +03:00
parent ea3a9e157e
commit bb44b1b1aa
2 changed files with 10 additions and 2 deletions
@@ -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<OrthoViewportInfo> Viewports { get; init; } = Array.Empty<OrthoViewportInfo>();
public IReadOnlyList<RuntimeDiagnostic> Diagnostics { get; init; } = Array.Empty<RuntimeDiagnostic>();
public OrthoDetectionResult Detection { get; init; } = new() { Status = OrthoDetectionStatus.Unsupported, Evidence = Array.Empty<string>(), Diagnostics = Array.Empty<RuntimeDiagnostic>() };
@@ -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<RuntimeDiagnostic>(),
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<RuntimeDiagnostic>(),
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 } } }
};