feat: add p-rec-update plant 3d 2026 slice
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using Autodesk.AutoCAD.ApplicationServices;
|
||||
using Autodesk.AutoCAD.Runtime;
|
||||
using PRecUpdate.Core;
|
||||
using AcadApplication = Autodesk.AutoCAD.ApplicationServices.Application;
|
||||
|
||||
namespace PRecUpdate.Plant3D2026;
|
||||
|
||||
public sealed class EntryPoint : IExtensionApplication
|
||||
{
|
||||
public void Initialize()
|
||||
{
|
||||
RuntimeMarker.Write("AssemblyInitializeStarted");
|
||||
RuntimeMarker.Write("AssemblyInitializeCompleted");
|
||||
}
|
||||
|
||||
public void Terminate() => RuntimeMarker.Write("AssemblyTerminateCompleted");
|
||||
|
||||
// Preserves the legacy command name. Apply remains denied unless a future
|
||||
// controlled fixture adapter proves the legacy Plant/DataLinks semantics.
|
||||
[CommandMethod("P-R-UPD", CommandFlags.Session)]
|
||||
public void UpdateCommand() => ReportPlan("P-R-UPD");
|
||||
|
||||
[CommandMethod("P-R-UPD-STATUS", CommandFlags.Session)]
|
||||
public void StatusCommand() => ReportPlan("P-R-UPD-STATUS");
|
||||
|
||||
private static void ReportPlan(string command)
|
||||
{
|
||||
var document = AcadApplication.DocumentManager.MdiActiveDocument;
|
||||
var plan = new UpdatePlanBuilder().Build(new UpdateRequest(
|
||||
document is not null,
|
||||
HasPlantProject(),
|
||||
HasPlantProject(),
|
||||
new HashSet<UpdateOperation>
|
||||
{
|
||||
UpdateOperation.ProjectNkr, UpdateOperation.Flanges,
|
||||
UpdateOperation.Fasteners, UpdateOperation.ProjectSpec
|
||||
},
|
||||
UpdateExecutionMode.DryRun,
|
||||
ControlledFixturePermit: false));
|
||||
document?.Editor.WriteMessage($"\nP_Rec_Update {command}: {(plan.Accepted ? "DryRun planned; no project data changed." : string.Join(", ", plan.Diagnostics))}");
|
||||
RuntimeMarker.Write(plan.Accepted ? "CommandRegistrationVerified" : "CommandPreflightRejected");
|
||||
}
|
||||
|
||||
private static bool HasPlantProject()
|
||||
{
|
||||
try { return Autodesk.ProcessPower.PlantInstance.PlantApplication.CurrentProject is not null; }
|
||||
catch { return false; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user