Rotate Component based on axis mouse point of BoundingBox

Here’s one way you can try:

  1. Obtain the corner points of the selection box.
  2. For each side create an array of the points for that side - you would have six arrays of four points.
  3. For each set of points, create a plane (Geom.fit_plane_to_points)
  4. In your tool, get a ray for where the mouse is: view.pickray(x, y)
  5. Loop over your planes and intersect with the pickray.
  6. 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.
  7. Collect the distance to the valid intersections and use the closest one as the best match.
2 Likes