feat: add controlled p-rec-annot line-number apply

This commit is contained in:
codex
2026-08-07 08:58:38 +03:00
parent 58f71267a2
commit 3128568965
2 changed files with 50 additions and 0 deletions
@@ -98,6 +98,19 @@ public sealed class EntryPoint : IExtensionApplication
var operations = string.Join(", ", preview.Plan!.Operations.Select(value => $"{value.Kind}:{value.Text}"));
editor.WriteMessage($"\nPXP-LN preview: {operations}. DWG не изменён.");
RuntimeDiagnostics.Write("LineNumberPreviewCompleted", commandName: "PXP-LN", resultStatus: "PreviewCompleted", document: document, details: new Dictionary<string, object?> { ["OperationCount"] = preview.Apply.Count });
if (ParseMode(RuntimeDiagnostics.RuntimeMode) != PRecAnnotExecutionMode.Apply) return;
var operation = preview.Apply.SingleOrDefault() ?? throw new InvalidOperationException("LINE_NUMBER_APPLY_REQUIRES_EXACTLY_ONE_OPERATION");
var placement = editor.GetPoint("\nУкажите положение маркера номера линии: ");
if (placement.Status != PromptStatus.OK) return;
operation = operation with { Position = new AnnotationPoint(placement.Value.X, placement.Value.Y, placement.Value.Z) };
var permit = LineNumberApplyPermitReader.Read();
LineNumberApplyPermitReader.Validate(document, permit, operation);
// AutoCAD wraps a command's committed transaction in its native
// UNDO record. No compensating-delete path is used here.
var result = new LineNumberAnnotationWriter().Apply(document, [operation], configuration.Assets);
RuntimeDiagnostics.Write("LineNumberApplyCompleted", commandName: "PXP-LN", resultStatus: result.Created > 0 ? "Created" : result.Updated > 0 ? "Updated" : "AlreadyCurrent", document: document, details: new Dictionary<string, object?> { ["Created"] = result.Created, ["Updated"] = result.Updated, ["AlreadyCurrent"] = result.Unchanged });
editor.WriteMessage($"\nPXP-LN Apply: created={result.Created}; updated={result.Updated}; already-current={result.Unchanged}.");
}
catch (System.Exception exception)
{