I'd like to enable Surface Project and set the orientation mode of the 3D Cursor from python, as if I did it from the header's tool settings. Note that I only want to change its settings, not move the cursor in the process.

For example I'm pretty sure that

bpy.ops.view3d.cursor3d(use_depth=True, orientation='GEOM')

requires to move the cursor.

So I looked inside




by tabbing like crazy in the tree of python objects but didn't find those settings.

Is it actually possible to change them from python?


You can set the active tool using bpy.ops.wm.tool_set_by_id(name = "builtin.cursor") and use ToolSelectPanelHelper class to get a reference to it. Code based on Operator Simple template:

import bpy
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper

class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

    def execute(self, context):
        # Set the cursor tool
        bpy.ops.wm.tool_set_by_id(name = "builtin.cursor")
        # Get the tool
        tool = ToolSelectPanelHelper.tool_active_from_context(context)
        # Set the properties
        props = tool.operator_properties('view3d.cursor3d')
        props.use_depth = False
        props.orientation = 'GEOM'

        # Print all properties
        print (dir(props)) 
        # [..., '__slots__', 'bl_rna', 'orientation', 'rna_type', 'use_depth']        
        return {'FINISHED'}

addon_keymaps = []

def register():

    # Add a shortcut
    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        km = wm.keyconfigs.addon.keymaps.new(name='3D View', space_type='VIEW_3D')
        kmi = km.keymap_items.new(
            SimpleOperator.bl_idname, type='C', value='PRESS', ctrl=True, shift=True)
        addon_keymaps.append((km, kmi))

def unregister():

    # Remove the shortcut
    for km, kmi in addon_keymaps:

if __name__ == "__main__":

Just run the script (or install as add-on) and press CtrlShiftC to enable the Cursor Tool along with your custom properties (use_depth, orientation in this case).


Use bpy.ops.transform.translate()

With the argument cursor_transform=True to apply the transformation on cursor instead of selected object

You can find other arguments of this operator here https://docs.blender.org/api/current/bpy.ops.transform.html

  • $\begingroup$ I only want to change the cursor tool's settings, not to move the cursor. $\endgroup$ – ChameleonScales May 27 '20 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.