Creating a new RhinoDoc invalidates existing one

For some reason exception b is being thrown? Why would creating a new Rhino doc seemingly invalidate all of the brep ids from the previous RhinoDoc?

         RhinoDoc prevDoc = RhinoDoc.ActiveDoc;
         List<Guid> ids = [id1, id2, id3];

         foreach (var id in ids)
         {
             if (prevDoc.Objects.FindId(id) == null) {
                 throw new Exception("a");
             }
         }

         var newDoc = RhinoDoc.Create(null);
         
         foreach (var id in ids)
         {
             if (prevDoc.Objects.FindId(id) == null) {
                 throw new Exception("b");
             }
         }

This question is very similar to RhinoDoc.Create invalidates object ids for other RhinoDoc therefore the same answer:

If you want to create a document that is not associated with a running Rhino, use RhinoDoc.CreateHeadless(templateFile) instead of RhinoDoc.Create(templateFile)

https://developer.rhino3d.com/api/rhinocommon/rhino.rhinodoc/createheadless#(string)

1 Like

Yes, but I don’t think I want a headless doc. I want to do some rendering, and save my renderings to png. As far as I can tell, no rendering is possible in a headless doc. Am I mistaken?