Hi everyone
I am trying to show all curves with the same name on one DetailView, but ZoomBoundingBox does nothing and returns False. When I am using SetCameraTarget method, it works and correctly places camera in center of the objects, but of course scaling is not proper, so I want to do this by bounding box. Here is my code:
from scriptcontext import doc
import rhinoscriptsyntax as rs
import Rhino
def getZonesNames(borders):
names=[]
names.append(rs.ObjectName(borders[0]))
for curve in borders:
if not names.count(rs.ObjectName(curve)):
names.append(rs.ObjectName(curve))
return names
borders=rs.ObjectsByLayer("Heating Zones")
zone_names=getZonesNames(borders)
doc.PageUnitSystem = Rhino.UnitSystem.Millimeters
page_views = doc.Views.GetPageViews()
page_number = 1
if page_views: page_number = len(page_views) + 1
for name in zone_names:
pageview=doc.Views.AddPageView(name,420,297)
if pageview:
top_left = Rhino.Geometry.Point2d(20,277)
bottom_right = Rhino.Geometry.Point2d(400, 20)
detail = pageview.AddDetailView(name, top_left, bottom_right, Rhino.Display.DefinedViewportProjection.Right)
if detail:
pageview.SetActiveDetail(detail.Id)
zone_curves=rs.ObjectsByName(name)
box=rs.coercecurve(zone_curves[0]).GetBoundingBox(False)
for curve in zone_curves:
ccurve=rs.coercecurve(curve)
if ccurve:
box2=ccurve.GetBoundingBox(False)
box=Rhino.Geometry.BoundingBox.Union(box,box2)
b=detail.Viewport.ZoomBoundingBox(box)
#b=detail.Viewport.SetCameraTarget(box.Center,True)
detail.CommitChanges()
detail.CommitViewportChanges()
doc.Views.Redraw()
What am I doing wrong?
Maybe I should add that all curves are on a plane, so bounding box has 0mm dimension in one of the axies.