diff --git a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/ScriptDrivenFirstApplyAutomation.cs b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/ScriptDrivenFirstApplyAutomation.cs index b2afcb5..c5e75ae 100644 --- a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/ScriptDrivenFirstApplyAutomation.cs +++ b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/ScriptDrivenFirstApplyAutomation.cs @@ -2,6 +2,8 @@ using System.Text.Json; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Runtime; +using Autodesk.ProcessPower.PlantInstance; +using Autodesk.ProcessPower.ProjectManager; using AcadApplication = Autodesk.AutoCAD.ApplicationServices.Application; namespace PRecAnnot.Plant3D2026; @@ -36,6 +38,10 @@ internal static class ScriptDrivenFirstApplyAutomation fixture.CommandEnded += OnEnded; fixture.CommandFailed += OnFailed; fixture.CommandCancelled += OnCancelled; + var projectXml = Path.Combine(Path.GetDirectoryName(config.FixtureMarkerPath)!, "Project.xml"); + if (!File.Exists(projectXml)) throw new InvalidOperationException("AUTOMATION_PROJECT_XML_MISSING"); + var project = PlantProject.LoadProject(projectXml, false, string.Empty, string.Empty); + PlantApplication.SetCurrentProject(project, true); var context = new PlantRuntimeContextReader().ReadCurrentContext(fixture); if (!context.HasPlantProject || !context.IsOrthoDrawing || context.Viewports.Count != 1) throw new InvalidOperationException("AUTOMATION_ORTHO_CONTEXT_INVALID");