I’m trying to automate SelCrossing <Point1> <Point2>
command to select everything visible in the current viewport (detail view on a layout sheet). What’s the best way to “convert” viewport corners to “real world” coordinates?
For example:
I’m trying to automate SelCrossing <Point1> <Point2>
command to select everything visible in the current viewport (detail view on a layout sheet). What’s the best way to “convert” viewport corners to “real world” coordinates?
For example:
from Rhino.DocObjects import ObjectType
from Rhino.Geometry import Point2d
import scriptcontext as sc
sc.doc.Objects.UnselectAll()
viewport = sc.doc.Views.ActiveView.ActiveViewport
first_corner = Point2d(viewport.Bounds.Left, viewport.Bounds.Bottom)
second_corner = Point2d(viewport.Bounds.Right, viewport.Bounds.Top)
rhino_objects = sc.doc.Objects.FindByCrossingWindowRegion(viewport,
first_corner, second_corner, True, ObjectType.AnyObject)
for obj in rhino_objects:
obj.Select(True)
Amazing, thank you very much! I would have never thought to look into sc.doc.Objects.FindByCrossingWindowRegion
function.
That is really helpful - I will use it to automate Make2D. It should be smooth sailing from here.