Set Active and Maximize a NamedViewport

hi,
How to set a namedViewport active in the main view and then maximize it ?
thx

var namedViewTable = Rhino.RhinoDoc.ActiveDoc.NamedViews;                  
var viewTable = Rhino.RhinoDoc.ActiveDoc.Views;
            
Rhino.Display.RhinoView [] rv = viewTable.GetViewList(true, false);
           
if (rv.Length > 0) { rv[0].Maximized = true; }

all right let’s try to better explain my issue…
I basically define some namedViews using rhino UI. How to display and maximize one of the predefined namedView using RhinoCommon ?
Right now I can set active and maximize a standard view (Top, Bottom, Left, Right). I didn’t find any rhinocommon method that allows to add the NamedViews to the Rhino.Display.RhinoView array but I guess there is another way to do it…

Rhino.DocObjects.Tables.NamedViewTable nvt = Rhino.RhinoDoc.ActiveDoc.NamedViews;
Rhino.DocObjects.Tables.ViewTable vt = Rhino.RhinoDoc.ActiveDoc.Views;

Rhino.Display.RhinoView [] rvs = vt.GetViewList(true, false);
Rhino.Display.RhinoViewport rvp = rvs[0].ActiveViewport;
rvs[0].Maximized = true; //this works good

How about this:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  RhinoView view = doc.Views.ActiveView;
  if (null == view)
    return Result.Failure;

  string name = null;
  Result rc = RhinoGet.GetString("Named view to restore", false, ref name);
  if (rc != Result.Success || string.IsNullOrEmpty(name))
    return Result.Cancel;

  int index = doc.NamedViews.FindByName(name);
  if (index < 0 || index >= doc.NamedViews.Count)
  {
    RhinoApp.WriteLine("Named view not found");
    return Result.Nothing;
  }

  doc.NamedViews.Restore(index, view, false);
  view.Maximized = true;
  view.Redraw();

  return Result.Success;
}

ok I was far away from what you sent…thx

Hi Dale,
the NamedViews.Restore method is not working in my case…
Actually the index value seems not being considered as I tried some out of bounds value and didn’t get any exception…

rh.RhinoDoc.ActiveDoc.NamedViews.Restore(100000, view, False)
import rhinoscriptsyntax as rs
import Rhino as rh

def NamedViewActive():
    
    view = rh.RhinoDoc.ActiveDoc.Views.ActiveView
    if (view == None):
        print "No Active View"
        return None
    else:
        print "Active View is: ", view.MainViewport.Name
    
    namedViews  = rh.RhinoDoc.ActiveDoc.NamedViews
    if (namedViews == None):
        print "No Named View"
        return None
    else:
        if(namedViews.Count>0):
            name = namedViews[0].Name
            print "name: ", name
            index = rh.RhinoDoc.ActiveDoc.NamedViews.FindByName(name)
            print "index: ", index
            rh.RhinoDoc.ActiveDoc.NamedViews.Restore(index, view, False)
            view.Maximized = True
            view.Redraw()

if( __name__ == '__main__' ):
    NamedViewActive()

ok. sounds like a bug…

do you know when the SR9 will be issued ?