I would like to create an operator that would trigger a pie menu containing the "pivot center modes" in it (median point, individual origins, 3d cursor, ...).

Now I could get started with the code below (from that topic: bpy: how do I list the "pivot center for rotation/scaling" items?

import bpy

def piebut(self, context):
    layout = self.layout
    op = layout.operator("wm.context_pie_enum")
    op.data_path = "space_data.pivot_point"

def register():

def unregister():

if __name__ == "__main__":

The code above will add a button to the 3dView header, and when you press that button, it will display a pie menu with the "pivot center modes" items in it.

However, I would like to convert this to an operator, so that I can ultimately press a shortcut key to open the pie menu directly (without having to click a button).

Now I've tried this without luck:

import bpy

class LING_OT_PIEMENU_PivotCenterModes(bpy.types.Operator):
    """A pie menu to select the pivot center for rotation and scaling"""
    bl_idname = "view3d.ling_piemenu_pivot_center_modes"
    bl_label = "Pivot center for rotation/scaling"

    def execute(self, context):
        bpy.ops.wm.context_pie_enum("space_data.pivot_point" )
        return {'FINISHED'}

# just for quick testing inside the blend file

I've changed those lines:

layout = self.layout
op = layout.operator("wm.context_pie_enum")

to this line:

bpy.ops.wm.context_pie_enum("space_data.pivot_point" )

because layout = self.layout was returning a None type, so I thought the layout property was not available from the operator class, and so I tried to call the context_pie_enum method in a different manner, but now I've got this error:


1 Answer 1


It already is an operator.

There is no need to create another operator to call an operator, so it can be given a shortcut.

Can add a keymap to it directly. The field to data_path ignore if appears disabled, select and type in the required RNA path from context.

enter image description here shortcut set to ⇧ Shiftz (disabled the toggle render shading)

or created via code (example)

import bpy

wm = bpy.context.window_manager
kc = wm.keyconfigs.user

km = kc.keymaps['3D View']
kmi = km.keymap_items.new('wm.context_pie_enum', 'Z', 'PRESS', shift=True)
kmi.properties.data_path = "space_data.pivot_point"

Alternatively it can be added as an expanding pie menu item in your original question code via

op = pie.operator("wm.context_pie_enum")
op.data_path = "space_data.pivot_point"

To call an operator from code, all operator properties must be passed as keyword arguments


The first argument of an operator call can be a string if it is one of the operator context enums, eg 'INVOKE_DEFAULT'. See error message in question for full list. Another type of argument is a dictionary of context override members.

bpy.ops.wm.context_pie_enum('INVOKE_DEFAULT', data_path="space_data.pivot_point") 
c = {"area": context.screen.areas[4]} # will need more than just area.
bpy.ops.wm.context_pie_enum(c, data_path="space_data.pivot_point")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .