I have a C# plugin that I start from the command line using the -WA switch so that it launches without the graphics interface.
Upon initialization I load in a DGN file like so:
DgnDoc = DgnDocument.CreateForLocalFile(DgnName); FileOwner = DgnFile.Create(DgnDoc, DgnFileOpenMode.ReadOnly); DgnFile file = FileOwner.DgnFile; file.LoadDgnFile(out StatusInt status); DgnModel model = file.LoadRootModelById(out StatusInt modelStatus, file.DefaultModelId); return (status == StatusInt.Success && modelStatus == StatusInt.Success);
Later in the application I would like to retrieve data from the loaded mdoel, so I use
Session.Instance.GetActiveDgnModel()
However this returns null as if there is no active dgn model, even though I just loaded one. If I open the application without -WA and run it from the user interface GetActiveDgnModel always returns the active file as long as a model is loaded.
So my question is, when does the ActiveDgnModel get set? and is there a way to set this manually?As far as I've been able to see there is no method to set the active model in either session, File or DgnModel.