Drag the mouse to create a rectangular window, can I get the coordinates of the window?

Drag the mouse to create a rectangular window, can I get the vertex coordinates of the window?

We need a little more information what you want to achieve.

The screenshot shows that you are using the native Select Tool. There is no possibility by Ruby API to get the coordinates of “vertex” of the drawn rectangle on screen.

However using:
#Class: Sketchup::Tool
interface that you implement to create your own SketchUp tool, and design the interface to achieve your goal (whatever it is :wink:).
E.g.:
code example
github.com/SketchUp/sketchup-ruby-api-tutorials


Actually there could be two “kind” of coordinates:

  • the screen coordinates (it is 2D coordinates and representing the viewport coordinates), e.g. x, y parameters in the #onMouseMove method or
  • 3D coordinates in the modell e.g. the InputPoint class is used to pick 3d points and/or entities that reside under the current cursor location (the #position method will return the Point3d as “coordinates” )

… and along with a Ruby tool you can use Sketchup::PickHelper#window_pick() to achieve the same result as the native SelectTool.

1 Like

Thank you for your answer, your guidance is related to what I want to do, I want to take it and learn it. And I’m going to ask you again about my question.
The red arrow marks the box that the mouse pulls out of the screen, and the green arrow marks the polygon, and I want to get the coordinates of the face that is equal in size and shape to the mouse box and is coplanar with the face of the green arrow。
I would like to know the feasibility of this question from your professional point of view

6e471e7ac7e430db385e74fa443da76

The problem is that the mouse picking box is drawn in 2D screen space and faces exist in 3D model space.

I think that you should study the example Shapes extension code.

You then need to convert the face’s 3D coords to 2D screen coordinates: