When placing the 3d cursor in the scene, I want to be able to snap it to vertices, grid points, edges or faces etc, .
Currently to place the cursor you have to click randomly in the 3d viewport, OR first create an object at the location you want and use Shift + s to snap the cursor to selected etc. This method works quite alright for some cases, but it is backwards for me.
I know I can use, bpy.context.scene.cursor_location = (x, y, z)
.
The only problem with this is that I have to know the coordinates before hand, which undermines the purpose of the cursor for me, in such use cases as I will show below.
I searched and found bpy.ops.view3d.cursor3d()
this is the command to interactively set the cursor location in the 3d viewport.
Is it possible (please show me how) to tweak that function in python to enable me to interactively snap to grids and vertices, (maybe faces and edges too) while I hover my mouse around the viewport, rather than clicking randomly in the 3d viewport, or having to use one of the shift + s modes of cursor snapping.
Blender 2.8’s new “set cursor button” seems to be leaning in that direction, but without the snapping.
In the long run I am trying to make an add-on to enable me interactively add objects(for a start) e. g
(below an example of how I think it might work, please pardon any syntax errors in my code sample below)
def place_cube():
""" set 3d cursor location interactively and add a cube at cursor location """
# here comes the interactive cursor placement by snapping
# ( for now it is not interactive, I need help here)
bpy.ops.view3d.cursor3d()
# standard add mesh cube function
bpy.ops.mesh.primitive_cube_add(radius=1)
So in the example above, I have effectively killed two birds with one stone, saving my self the initial (or subsequent, as the case my be) step of “set cursor to center, or selection etc” before the “add cube” command.
I really hope I have made my explanation clear enough. Thanks
P. S I use blender for Architectural work, at times , adding and moving objects tends to be done in precise ways that would benefit from this kind of interactive cursor placement mode.