Possible to snap cursor to faces and vertices in object mode?


Is it possible to snap cursor to faces and vertices in object mode with (or without) Python/Blender API in Blender 2.8x ?

If so, where should I take a look at in the Blender API documentation?

Unless I’m misunderstanding, snapping already applies to the 3d cursor.

If you’ve got snapping set to vertex and use the dragging 3d cursor placement, SHIFT+RMB (maybe LMB) it’ll snap to the nearest vertex. Snapping is the same as in edit mode so it’s either toggle enabled, or enabled by holding CTRL.

If you specifically need it in python you can find surface points with ray intersection. I believe one of the script templates does this.

For vertices I think you’d need to do some sphere ray intersection for each vertex. Or maybe convert the vertices to screen space and find the closest point to cursor. I don’t know which would be faster, presumable the latter.

Ahw, Thanks
I use snapping frequently but didn’t come to mind that it works also for the cursor. (With SHIFT+RMB, and if you don’t have snapping on, Ctrl while dragging.)
Snapping to center of Edge is one of the things I am looking for, so that works.
But it seems that snapping the cursor to the center of a face (which I use the most) is not possible this way.

I will look at surface points with ray intersection. Or maybe temporally use subdiv modifier (simple) if that’s not so much hassle.

You are probably looking for this, but it has not been ported to 2.8x I think.

In the discription I see: “cursor can be snapped to grid/vertices/edges/faces/boundbox/objects”. Not sure if that is also center of a face.
The latest version, according to thread is for blender 2.7.7. The code looks impressive to me.
I think I do it with a temporally subdivide modifier (simple) for now.