I use cursor depth to snap the 3d cursor on my object. I want select the face corresponding the 3d cursor. There is a tricks with Blender python API ?
Exemple (Before/After) :
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityI use cursor depth to snap the 3d cursor on my object. I want select the face corresponding the 3d cursor. There is a tricks with Blender python API ?
Exemple (Before/After) :
Try this (requires you to have one selected and active mesh object):
import bpy
cur = bpy.context.scene.cursor_location
o = bpy.context.object
bpy.ops.object.mode_set( mode = 'OBJECT' )
faceIdx = o.closest_point_on_mesh( cur )[-1]
if faceIdx != -1:
o.data.polygons[ faceIdx ].select = True
bpy.ops.object.mode_set( mode = 'EDIT' )
AFAIK you cannot select a face with the 3D cursor, but Shift+S > Cursor to selected will put it at the center of the face or face group... I think this is what you're asking. Also Shift+S has other settings for direct placement in relation to 3D cursor. they are named
they do exactly what they sound like.