Baking objects in Layout mode and switching views: two correlated bugs in Grasshopper...?

Hello, dear Community,

I am developing a small assembly to automate the generation of pdfs straight out of Grasshopper.
Working on it, I have noticed that Grasshopper, while Rhino is in Layout mode, bakes its geometries not to the ModelSpace, but to the PageSpace:


This seems to happen not just while using the built-in Bake method, but also by adding the geometries ‘manually’ to the Rhino document via the myRhinoDoc.Objects.Add(obj, att) method. Specifying that we want the ObjectAttributes.Space property set as ‘ModelSpace’ doesn’t help either.

Since the users of my component will likely run it while checking their page Layouts, I needed some sort of workaround to prevent that.
What I came up with, simply, is forcing Rhino to switch back and forth during the component execution between Standard and Page Views.


This works, but as it switches back to the initial page view, the Grasshopper canvas freezes: everything seems to keep functioning as normal (Rhino, the Grasshopper menu bar…), except the ability to pan the canvas and interacting with the components on it.

To replicate the bug:

  1. Open a new Rhino document, and create a new Layout (by default named Page1).
  2. While on the Layout, open this Gh document and run the script by hitting the boolean button: bug.gh (4.1 KB)
  3. Now, try to pan across the canvas…

Is there any way I can force Gh to ‘reboot’ the canvas after that line of code?

Thank you very much for your time looking into this.