Cannot manipulate detail viewport


I was trying to manipulate the detail viewport through rhino python, without avail. The viewport does not change. I tried ZoomBoundingBox and ZoomExtentsSelected, neither of them worked. I don’t know whether I am missing some steps. I am on Rhino 6.18.

Thanks for advices,

import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs

guid = rs.GetObject()
obj = rs.coercerhinoobject(guid)
#obj is the rhinoobject I want the viewport to zoom at

newView = sc.doc.Views.AddPageView("newpageview", 200, 200)
# add detail
detail = newView.AddDetailView("test", Rhino.Geometry.Point2d(0,0), Rhino.Geometry.Point2d(200,200), Rhino.Display.DefinedViewportProjection.Top)
bbox = obj.Geometry.GetBoundingBox(True)
viewport = detail.Viewport
print viewport.CameraTarget
viewport.SetCameraTarget(bbox.Center, True) # move location
print viewport.CameraTarget
# the CameraTarget did changed

Hi @vincentfs have a look at script nr 5 in my page layout tools
You need to make transformations to accomplish this.

Hi @Gijs , I tried your layout tools. They look great. I looked into the “” one especially. The transformations you mentioned seems to be for the detail shape (ie. its geometry). I was hoping the change its viewport content without moving the detail geometry.

ah, yes, sorry, I now see that what you need is different. Basically you want to pan and zoom into the detail view. The script I referred to will match the scale and align the content with the detail crop window instead. So you want the crop window to stay in place and zoom/pan. I’ll take a look if I can find something that does this.

Exactly. I feel I am missing some steps during manipulating the Rhino.Display.RhinoViewport. I cannot find an example code for this. It would be great if you can help look into this.

I think @pascal needs to help here, because I also cannot get either viewport.SetCameraTarget nor viewport.ZoomBoundingBox to work.

Hi @vincentfs,

Does this help?

– Dale

Hi @dale and for anyone that has the same question,

I end up using the following hack:

sc.doc.Views.ActiveView = pageview
rs.Command("_Zoom _Selected", False)

Just curious, what is the difference between sc.doc.Views.ActiveView = pageview and pageview.SetPageAsActive(). I found that the former is essential for rs.Command to work. I haven’t used the later.

Hi @vincentfs,

ViewTable.ActiveView sets the active view (window).

RhinoPageView.SetPageAsActive sets the layout view, of a RhinoPageLayout, active. To set a detail, of a RhinoPageView, active use RhinoPageView.SetActiveDetail.

– Dale

– Da;e