Camera Setting on Detail

Hi

I am trying to set up a camera with a Namedview on a detail using python.
The way I structured is

  1. setup a camera location, up and target and save as a Named view
  2. Create a layout,
  3. Create a detail,
  4. Change the Camera location, up, target under the detail and then commit changes.

so from task 3) the code looks like

detail = layout.AddDetailView(“dName_{0}”.format(page_number), top_left, bottom_right, Rhino.Display.DefinedViewportProjection.Top)
if detail:
layout.SetActiveDetail(detail.Id)
detail.Viewport.SetCameraLocation(NamedView.CameraLocation,False)
detail.Viewport.SetCameraDirection(NamedVIew.CameraDirection,False)
detail.Viewport.CameraUp = NamedView.CameraUp
detail.CommitChanges()

This is how I change the camera setting.(NamedVIew here is viewportinfo from the saved NamedView)

However, even if the values such as cameraLocation, Direction, and target, are changed, the end layout with the detail is back to the top view.

Or is there a way to move and set a camera under a detail? I am willing to take any suggestions on setting multiple layouts and multiple details with multiple views through scripting.

Thanks,

Nevermind. I figured. Everything worked fine using detail.CommitViewportChanges() before detail.CommitChanges()

And any non-Viewportchages before CommitViewportChanges seems to un-do all the viewport changes.

Thank you.