Try the following script. When you execute it in the Text Editor
, it will set the 3D Cursor
at the center of the position of your current view in the 3D Viewport. Notice that after I execute the script, I slightly zoom out so you can see the position of the 3D Cursor where previously the view of 3D Viewport was located at.
import bpy
area = next(area for area in bpy.context.window.screen.areas if area.type == 'VIEW_3D')
current_location = area.spaces.active.region_3d.view_matrix.inverted().translation
print("Location of Current View:", current_location)
bpy.context.scene.cursor.location = current_location