Navigating within Detail View

Hi,

I have found this good example of adding a Detail View. I see that Zoom Extents is used for zooming but cannot find how can I use ZoomWindow in a similar way? The reason is because I need to control which part of the Viewport to be shown within Detail View.
Ideally would be to specify point in model layout that should correspond to the center point of Detail View.
Any thoughts?
@dale , maybe you can advise?

      If pageview IsNot Nothing Then
          Dim top_left As New Rhino.Geometry.Point2d(20, 821)
          Dim bottom_right As New Rhino.Geometry.Point2d(1169, 20)
          Dim detail = pageview.AddDetailView("ModelView", top_left, bottom_right, Rhino.Display.DefinedViewportProjection.Top)
          If detail IsNot Nothing Then
            pageview.SetActiveDetail(detail.Id)
            detail.Viewport.ZoomExtents()
            detail.DetailGeometry.IsProjectionLocked = True
            detail.DetailGeometry.SetScale(1, doc.ModelUnitSystem, 10, doc.PageUnitSystem)
            ' Commit changes tells the document to replace the document's detail object
            ' with the modified one that we just adjusted
            detail.CommitChanges()
          End If
          pageview.SetPageAsActive()
          doc.Views.ActiveView = pageview
          doc.Views.Redraw()
          Return Rhino.Commands.Result.Success
        End If

Thanks in advance,
Dmitriy

It may not tie in with what you are attempting, but if you created a named view in modelspace then called that view in the script, followed by a scale adjustment.

Basically I am trying to show certain area from model space within Detail View.
I have also tried ZoomBoundingBox, but not sure how this works.
Any further suggestion is highly appreciated.

Thanks,
Dmitriy

Hi Dmitriy, the snippet below will create a scaled detail in a new layout page showing a named view, if launched from modelspace, so hopefully you can use or adapt it to get your code working

'*** Check that current view is 'perspective' ______________________________ ***

  Dim blnResult, str_CurrentView
  
    str_CurrentView = Rhino.CurrentView   
  
  blnResult = Rhino.IsViewPerspective(str_CurrentView)
 '*** persepective view in detail cannot be scaled
  If blnResult = True Then
    Rhino.Command "_SetView _World _Top "
  End If

'*** Create named view within script_______________________________________ *** 

  Dim str_NamedView
  
   Call Rhino.EnableReDraw(False)  
           Rhino.UnSelectAllObjects
  
    str_NamedView = "NamedView 01"          '*** change named view here

  If Not IsNull(str_NamedView)Then
    Rhino.AddNamedView str_NamedView, str_CurrentView
  End If

  If Rhino.IsLayout(str_NamedView) Then
    Rhino.Print "Page is already present"
    Call Rhino.EnableRedraw(True)      
    Exit Sub                                                      'Escape Route
  End If 
 
'*** Rhino command - create  the layout page _______________________________ ***
  
  Dim str_PageName, dbl_PageWidth, dbl_PageHeight, dbl_Details, cmd_Layout
    
    str_PageName =   "Test_01"    '***  page name, no spaces
    dbl_PageWidth = 297                     '*** page size/orientation
    dbl_PageHeight = 210   
    dbl_Details = 0                                  '*** no of details
    
    cmd_Layout = "_-Layout " & VbCrLf 
    cmd_Layout = cmd_Layout & str_PageName & VbCrLf
    cmd_Layout = cmd_Layout & dbl_PageWidth & VbCrLf
    cmd_Layout = cmd_Layout & dbl_PageHeight & VbCrLf
    cmd_Layout = cmd_Layout & dbl_Details                  
    
  If Not IsNull(cmd_Layout)Then
    Rhino.Command cmd_Layout, False
  End If 

'*** Rhino command - Add detail to layout page _____________________________ ***
  
  Dim str_Projection, arr_1stCorner, arr_2ndCorner, cmd_Detail 
   
    str_Projection = "Top"
    arr_1stCorner = Array(10,33,0)                     '*** Page detail location
    arr_2ndCorner = Array(287,187,0) 
   
    cmd_Detail = "_-Detail _Add " & VbCrLf 
    cmd_Detail = cmd_Detail & "_Projection=" & str_Projection & VbCrLf    
    cmd_Detail = cmd_Detail & Rhino.Pt2Str(arr_1stCorner) & VbCrLf
    cmd_Detail = cmd_Detail & Rhino.Pt2Str(arr_2ndCorner)

  If Not IsNull(cmd_Detail)Then
    Rhino.Command cmd_Detail, False
  End If 

'*** Select the detail for enabling and scaling ____________________________ ***

  Dim arr_VPort
   
    arr_VPort = Rhino.LastCreatedObjects        '*** command result

  If Not IsNull(arr_VPort) Then
    Rhino.ObjectName arr_VPort, "Detail_01"  '*** optional
    Rhino.SelectObjects arr_VPort
  End If

'*** Rhino command - enable the detail and call named view _________________ ***
  
  Dim cmd_Enable, cmd_Display 
 
    cmd_Enable  = "_-Detail _Enable "
  
  If Not IsNull(cmd_Enable)Then 
    Rhino.Command cmd_Enable, False
  End If

    Rhino.RestoreNamedView str_NamedView 

'*** Rhino command - Add scale to viewport _________________________________ ***
  
  Dim dbl_DetailScale, cmd_Scale 
   
   dbl_DetailScale = 10                   '*** change detail scale here
   
    cmd_Scale  = "_-Detail _Scale  " & VbCrLf 
    cmd_Scale  = cmd_Scale  & 1 & VbCrLf    
    cmd_Scale  = cmd_Scale  & dbl_DetailScale   
    
  If Not IsNull(cmd_Scale) Then
    Rhino.Command cmd_Scale, False
  End If

'*** De-activate detail  ___________________________________________________ ***
  
  Dim cmd_Disable
    
    cmd_Disable  = "_-Detail _EnablePage "
  
  If Not IsNull(cmd_Disable)Then  
    Rhino.Command cmd_Disable, False
  End If
 
  Call Rhino.EnableReDraw(True)

Hi Brian,

Thanks for your reply.
Actually all the steps you mentioned have been done already in the code I posted above but however I cannot control what area should be scaled.
I presume that ZoomBoundingBox in Viewport should do the job but it doesn’t work, or at least I cannot see how it works.

Thanks,
Dmitriy

Oh yes, well maybe you could create a temp point object at the specific location you mentioned previously and name it, then zoom selected to it from inside the enabled detail, then zoom back out to the req’d scale and delete the point?

Hi Brian,

Finally I found a solution.
I have found this post: Positioning detail.viewport (top view) to a given point co-ordinate
CommitViewportChanges() makes it work.

Thanks,
Dmitriy