fix: defer Plant automation to first post-startup idle
This commit is contained in:
@@ -10,10 +10,23 @@ namespace PRecAnnot.Plant3D2026;
|
||||
|
||||
public sealed class EntryPoint : IExtensionApplication
|
||||
{
|
||||
private static bool automationQueued;
|
||||
public void Initialize()
|
||||
{
|
||||
RuntimeDiagnostics.Write("AssemblyInitializeStarted");
|
||||
RibbonIntegration.Register();
|
||||
if (string.Equals(Environment.GetEnvironmentVariable("P_REC_ANNOT_AUTOMATION"), "FirstLimitedApplyRuntimeTest", StringComparison.Ordinal) && !automationQueued)
|
||||
{
|
||||
try
|
||||
{
|
||||
automationQueued = true;
|
||||
FirstLimitedApplyAutomationBootstrap.Prepare();
|
||||
}
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
RuntimeDiagnostics.Write("AutomationBootstrapPreparationFailed", "ERROR", resultStatus: "AUTOMATION_BOOTSTRAP_FAILED", exception: exception);
|
||||
}
|
||||
}
|
||||
RuntimeDiagnostics.Write("AssemblyInitializeCompleted");
|
||||
}
|
||||
|
||||
@@ -33,6 +46,9 @@ public sealed class EntryPoint : IExtensionApplication
|
||||
[CommandMethod("PXP-OA")]
|
||||
public void OrthoAnnotateCommand() => RunDiagnostic("PXP-OA");
|
||||
|
||||
[CommandMethod("PHP_REC_AUTOMATION_START", CommandFlags.Session)]
|
||||
public void AutomationStartCommand() => FirstLimitedApplyAutomationBootstrap.Arm();
|
||||
|
||||
private static void RunDiagnostic(string commandName)
|
||||
{
|
||||
var operationId = Guid.NewGuid().ToString("N");
|
||||
@@ -80,6 +96,8 @@ public sealed class EntryPoint : IExtensionApplication
|
||||
var applyPermit = (mode == PRecAnnotExecutionMode.Apply || hasLimitedApplyPermit) && document is not null
|
||||
? FirstLimitedApplyPermitReader.ReadFor(document)
|
||||
: null;
|
||||
var automationTarget = FirstLimitedApplyAutomationCoordinator.SelectedTargetSnapshotId;
|
||||
var limitedTarget = applyPermit?.TargetSnapshotId ?? automationTarget;
|
||||
if (mode == PRecAnnotExecutionMode.Apply && context.Viewports.Count != 1)
|
||||
throw new InvalidOperationException("APPLY_REQUIRES_EXACTLY_ONE_VIEWPORT");
|
||||
|
||||
@@ -95,8 +113,8 @@ public sealed class EntryPoint : IExtensionApplication
|
||||
CommandName = commandName,
|
||||
Viewport = viewport,
|
||||
Objects = objects,
|
||||
LimitedApplyTargetSnapshotId = applyPermit?.TargetSnapshotId,
|
||||
LimitedApplyRuleId = applyPermit is null ? null : FirstLimitedApplyPlanner.RuleId
|
||||
LimitedApplyTargetSnapshotId = limitedTarget,
|
||||
LimitedApplyRuleId = limitedTarget is null ? null : FirstLimitedApplyPlanner.RuleId
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -141,6 +159,13 @@ public sealed class EntryPoint : IExtensionApplication
|
||||
details["PlanConflictCount"] = summary.ConflictCount;
|
||||
details["PlanUnsupportedCount"] = summary.UnsupportedCount;
|
||||
details["ErrorCount"] = summary.ErrorCount;
|
||||
if (string.Equals(commandName, "PXP-OA", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var candidates = objectsByViewport.SelectMany(x => x)
|
||||
.Where(x => string.Equals(x.ObjectClass, "Pipe", StringComparison.OrdinalIgnoreCase) && x.MembershipStatus == ViewMembershipStatus.Resolved && x.Geometry.PaperPosition is not null)
|
||||
.Select(x => x.SnapshotId).OrderBy(x => x, StringComparer.Ordinal).ToArray();
|
||||
FirstLimitedApplyAutomationCoordinator.RecordPxpOa(planId, candidates, context.Viewports.SingleOrDefault()?.Id, summary.CreateCount, summary.SkipCount, mode == PRecAnnotExecutionMode.Apply ? applyPermit is not null : null);
|
||||
}
|
||||
if (mode == PRecAnnotExecutionMode.Apply)
|
||||
{
|
||||
var corePermit = new FirstLimitedApplyPermit
|
||||
|
||||
Reference in New Issue
Block a user