Bug while trying to zoomExtend a detailView

rhinocommon
rhino5

#1

Hi,
I’ve got an issue when trying to ZoomExtents a DetailViewObject:
*If I set as active the detailView it seems to work, but as soon as I set back as active the pageView, everything is cancelled.
*Even stanger: If I breack the code with a dummy user action, it works! (for exemple: RhinoGet.GetBool(“PressEnterToContinue”, True, “”, “”, True)

I think this some kind of commit bug, here is my code:

   `Dim CoverSheetpageview As Rhino.Display.RhinoPageView = TryCast(doc.Views.ActiveView, Rhino.Display.RhinoPageView)
        CoverSheetpageview.PageName = "CoverSheet"
        Dim CoverSheetdetailview As Rhino.DocObjects.DetailViewObject = CoverSheetpageview.GetDetailViews(0)
        CoverSheetpageview.SetActiveDetail(CoverSheetdetailview.Id) 'activer le premier détail de la page en cours (a généraliser)
        CoverSheetdetailview.Viewport.ZoomExtents()
        CoverSheetdetailview.CommitViewportChanges()
        CoverSheetdetailview.CommitChanges()
        CoverSheetpageview.Redraw()
        'Désactiver le détail
        RhinoGet.GetBool("PressEnterToContinue", True, "", "", True)
        CoverSheetpageview.SetPageAsActive()
        doc.Views.ActiveView = CoverSheetpageview
        CoverSheetpageview.Redraw()`

(Dale Fugier) #2

Hi Matthieu.

Here is a viewport example:

Is this helpful?

– Dale


#3

Hi Dale,
Sorry it does not help, maybe I was not clear enought with my issue.

My code to zoom extent in a detailview works fine. The issue is when tring to set back the pageview as active.

When I do this:

CoverSheetpageview.SetPageAsActive()
doc.Views.ActiveView = CoverSheetpageview

the Zoom extent is not kept!

Do you get the issue?

Thanks for helping

Matthieu


(Dale Fugier) #4

No I am not seeing this.

This seems to work (too):

    Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result

      Dim pageView = TryCast(doc.Views.ActiveView, RhinoPageView)
      If pageView Is Nothing Then
        Return Result.Failure
      End If

      Dim details = pageView.GetDetailViews()
      If details Is Nothing OrElse 0 = details.Length Then
        Return Result.Failure
      End If

      pageView.PageName = "CoverSheet"

      For Each detail As DetailViewObject In details
        pageView.SetActiveDetail(detail.Id)
        detail.Viewport.ZoomExtents()
        detail.CommitViewportChanges()
        pageView.Redraw()
        RhinoApp.Wait()
      Next

      pageView.SetPageAsActive()
      pageView.Redraw()

      Dim tmp As String = Nothing
      RhinoGet.GetString("Press <Enter> to continue", True, tmp)

      doc.Views.ActiveView = pageView

      Return Result.Success

    End Function

#5

@dale, i think i am facing a similar problem with zooming in a detail viewport using Rhino 5 SR12. There clearly is a bug, i am trying to zoom to a bounding box like this:

pageview.SetActiveDetail(detail.Id)
detail.Viewport.ZoomBoundingBox(bbox)
detail.CommitViewportChanges()
detail.DetailGeometry.IsProjectionLocked = False
detail.DetailGeometry.SetScale(1.0, scriptcontext.doc.ModelUnitSystem, 1.0, scriptcontext.doc.PageUnitSystem)
detail.CommitChanges()

It seems that ZoomBoundingBox(bbox) does always zoom to the extents of the document content. If i add a point, very far away from my drawing which is not part of the bounding box i pass to the ZoomBoundingBox method, it zooms so this point is included.

If i select something during above code using rs.Command() and then use ZoomBoundingBoxSelected(), it also includes the point which is not selected and far away. How can i make it zoom the bounding box i passed ?

btw. under which circumstances does ZoomBoundingBox(bbox) return False ?

_
c.


(Dale Fugier) #6

Hi @clement,

Can you provide me a more complete code sample, that I can run here, that repeats what you are seeing?

– Dale


#7

Hi @Dale,

below is an example doc and script, i am trying to set the detail view projection so that the circle is centered using the bounding box. (RH5 SR12):

Example2.3dm (72.8 KB)
Example2.py (940 Bytes)
_
c.


(Dale Fugier) #8

Hi @clement,

If the detail is active, this works:

import rhinoscriptsyntax as rs
object_ids = rs.ObjectsByName('Circle')
bbox = rs.BoundingBox(object_ids)
rs.ZoomBoundingBox(bbox)

I haven’t had the attention span to figure out why you code isn’t working. So I’ve opened an issue so I can spend some time determining if this a bug or not.

https://mcneel.myjetbrains.com/youtrack/issue/RH-46102

– Dale