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,
Vincent
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
detail.CommitChanges()
sc.doc.Views.Redraw()
Hi @Gijs , I tried your layout tools. They look great. I looked into the “alignDetails.py” 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.
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.