Can't save doc opened through OpenDocumentFile method

Hi. GHPython throws the following exception when I try to programatically save documents I’m tinkering with:

Runtime error (InvalidOperationException): Saving is not allowed in the current application mode.

I am suspecting it’s not really a bug and has more to do with the GH window being open at the time of executing the script, since I was able to get it working just by opening the GHPython script window, then clicking outside the GH Window so only the script window is floating but GH is no longer visible (usually bothering behavior, but looks like it’s helping here), then running the script by clicking either “Test” or “OK”. I can submit the code if necessary.

Any plans to make saving and similar actions compatible with running the GH window at the same time? It’s not such a big deal right now since I can just make it work the way I described, but figured this behavior might be worth a look in the future.

Also, it’s such a shame that the Revit API itself seems to be limited regarding automated link creation (Group > Link conversion, or Shared Site setup and modification). I’m trying to develop a script which will create specific named locations in linked documents according to GH Planes in order to keep tidied-up information of their position and angle deviation to True North, but it like there’s some API functionality I’m missing or simply haven’t found yet. Not RiR’s problem, of course, but I just thought I could say it out loud. Will probably submit the idea if it’s not implemented in the API’s next release.

The .Save() method currently does not work inside the Grasshopper since the definition is updated by an event handler, triggered from Revit and thus document is marked as Editable and can not be saved. I have filed an issue for this:

Regarding your question about project locations, they are represented by DB.ProjectLocation which is a subclass of DB.Element. I think you can use the DB.ElementTransformUtils.CopyElements() method to copy the desired project location to another document.