I spent the last two days hard studying Ruby API, and I’m struggling with an issue.
Wanna to do a Tool, like the RotateTool, but it needs to rotate 90 degrees based on the BoundingBox’s component axis.
If the mouse is over the top “face” of BoundingBox’s component, it needs to rotate 90 degrees over it’s own Z AXIS.
Just like the rule that appears when choose RotateTool. But don’t need to draw, just to rotate.
I don’t know how to get the center of the BoundingBox side to be the origin of rotation.
I have this for now:
def onLButtonDown(flags, x, y, view) ph = view.pick_helper ph.do_pick x,y element = ph.best_picked ip = view.inputpoint x, y face=ip.face #Based on Bound class of TTLib, maybe here's the problem too, #cause I need the BoundingBox of element, not the bounds of the face p1 = face.bounds.corner( 0 ) p2 = face.bounds.corner( 5 ) pt = Geom.linear_combination( 0.5, p1, 0.5, p2 ) rotate = Geom::Transformation.rotation pt, *here_is_the issue*, 90.degrees Sketchup.active_model.entities.transform_entities rotate, element end
here_is_the issue = I know it’s an axis (like [0,0,1] for Z), but how to get the current bounding “mouse over” axis?
That’s it, thanks