From bfd31a374707150a983ecb50b66207017974f1b3 Mon Sep 17 00:00:00 2001 From: codex Date: Tue, 4 Aug 2026 10:10:49 +0300 Subject: [PATCH] fix: activate fixture project in script preparation --- .../ScriptDrivenFirstApplyAutomation.cs | 6 ++++++ 1 file changed, 6 insertions(+) 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");