Creating a new viewport with python/rhinocommon

There is a very slight difference between RhinoDoc.ActiveDoc and scriptcontext.doc

  • When you are running Rhino python scripts on Windows, there is really no difference between the two
  • When you are running python scripts inside of Grasshopper, scriptcontext.doc is typically a “pseudo” doc that works well in the context of Grasshopper
  • When you are running Rhino python scripts on Mac, there are typically many docs and which one is “active” can be a little unclear. In this context scriptcontext.doc is always the doc that was active when the script started executing.

In general, it is typically best to use scriptcontext.doc instead of RhinoApp.ActiveDoc. This will make your scripts more “cross platform” capable.

3 Likes