Layout ZoomBoundingBox fails?

Hi everyone,

I am currently working on a Python script that enables me to create multiple layouts out of bounding curves and zooms the detail to each one of them. For some reason, the script only fails for the 1st curve on the list, not zooming in correctly. If you test for 1 curve (by only puttting on curve on the selection layer) the error becomes apparent.

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def AddLayout():
    sc.doc.PageUnitSystem = Rhino.UnitSystem.Millimeters
    page_views = sc.doc.Views.GetPageViews()
    page_number = 1
    if page_views: page_number = len(page_views) + 1
    pageview = sc.doc.Views.AddPageView("A0_{0}".format(page_number), 34, 20)
    if pageview:
        top_left = Rhino.Geometry.Point2d(0,0)
        bottom_right = Rhino.Geometry.Point2d(34, 20)
        detail = pageview.AddDetailView("ModelView", top_left, bottom_right, Rhino.Display.DefinedViewportProjection.Top)
        sc.doc.Views.ActiveView = pageview
        if detail:
            detail.DetailGeometry.SetScale(1, sc.doc.ModelUnitSystem, 1, sc.doc.PageUnitSystem)
            detail.DetailGeometry.IsProjectionLocked = True

layer = rs.GetLayer("Select Layer", None, False)
ids = rs.ObjectsByLayer(layer)
for id in ids:
    bounding_box = rs.coerceboundingbox(rs.BoundingBox(id))

This is the first layout (WRONG)

This is the second one and all that follow (RIGHT)

I leave my test file for anyone that wants to try. CatalogueExample04.3dm (163.5 KB)

I still wasn’t able to figure out why this is failing. Any ideas?

Hi @ShynnSup,

See if this help:

# Give Rhino a chance to catch up...

– Dale


Thank You Dale, that seems to have solved it!