Saving Rhino Views

Hello, I am actually the aforementioned student…

I managed to solve this issue myself by following the Rhino Syntax documentation and thought it might be useful for others to post it here. I rewrote the code as follows:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino as rc
# Firstly delete the existing NamedViews
if Num == -1:
    sc.doc = rc.RhinoDoc.ActiveDoc
    NamedViews = rs.NamedViews()
    for Name in NamedViews:
        rs.DeleteNamedView(Name)
    sc.doc = ghdoc
# Then I use Ladybug fly and Ladybug SetView to iterate through views & Save here, making sure to set active view first
if Num >= 0:
    sc.doc = rc.RhinoDoc.ActiveDoc
    rs.CurrentView(view = View2Save)
    rs.AddNamedView(ViewName, View2Save)
    sc.doc = ghdoc

The key issue was setting the active view before attempting to save NamedViews to ensure it saved the view from the Perspective Viewport.

All the best,

Ryan.

2 Likes