@ShynnSup wrote:
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) pageview.SetPageAsActive() sc.doc.Views.ActiveView = pageview if detail: pageview.SetActiveDetail(detail.Id) detail.Viewport.ZoomBoundingBox(bounding_box) detail.DetailGeometry.SetScale(1, sc.doc.ModelUnitSystem, 1, sc.doc.PageUnitSystem) detail.DetailGeometry.IsProjectionLocked = True detail.CommitChanges() sc.doc.Views.Redraw() layer = rs.GetLayer("Select Layer", None, False) ids = rs.ObjectsByLayer(layer) for id in ids: bounding_box = rs.coerceboundingbox(rs.BoundingBox(id)) AddLayout()
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)
Posts: 1
Participants: 1