Here’s one way you can try:
- Obtain the corner points of the selection box.
- For each side create an array of the points for that side - you would have six arrays of four points.
- For each set of points, create a plane (
Geom.fit_plane_to_points
) - In your tool, get a ray for where the mouse is:
view.pickray(x, y)
- Loop over your planes and intersect with the pickray.
- When you hit, transform the pickray and the points for that side into local 2d space - then you can use
Geom.point_in_polygon_2D
and see if the intersection from the ray and plane is within. - Collect the distance to the valid intersections and use the closest one as the best match.