Pie Menus (official) Customization

Idea, a Pie Menu to select bones… very difficult I guess but soooooo helpful.

+1
a very good idea, really!
select bones can be a real pain sometimes, both viewport and outliner selection.

paolo

Yeah, as you say, a real pain sometimes but I imagine that make a PM like that could be almost imposible, how do the PM know how many bones did you make? By name?

Easier would be if you adapt a PM to the addon “Rigify” for example I guess, but if you add or remove a single bone?

A PM like this is a dream, a really workflow speedboost but I don´t know if this could work.

It should not be so difficult, it should list all the bones belonging to the selected armature, but let it to some skilled coders, I have no competence.
Another problem could be how to manage/allow multiple selections.

Anyway I think that a regular pop up menu could be better for this task than a Pie.

paolo

Dont want to bother you guys but… another idea, XD. Yes I think about PMs quite a lot, they seems to me the perfect solution to get the fastest workflow and dont have to remember so many key shortcuts (Ctrl+Shift+Alt+C, "short"cut)…

Let me explain the image:


  • First of all, with sticky keys -> 29 options per key and if multilevel PMs are added… just imagine…
  • With this solution, PM and the cursor are recentered on the screen every time you press the key, solving the trouble we can find if you press the key with the cursor near the border. I dont think you can lose too much time getting back the cursor to the place you were working on. Besides, if you use PMs you are always moving your cursor (choosing options) from the place you were working so I think that you are used to that and if you get the cursor recentered is a good thing IMHO.
    - When you press the key, you just see 8 options, the other options suddenly appear and are visible when the cursor exceeds a certain radius value.
  • In multilevel PMs the cursor is recentered again when the second level appears.

Hi,

Someone can tell me what is the operator code for sculpt brush ?
I din’t find it.

data.brushes[“Blob”] dosn’t works.

Thanks pitiwazou!
For me it is a great time-saver.
I copied the code from the video and added the keymap definition “alt-tab”, so the “mesh select mode” menu (ctrl-tab) remains unchanged.
I learned a lot during copying, but I post it for a more comfortable copy and paste for those who need it, if you agree.



import bpy
from bpy.types import Menu

bl_info = {
    "name": "Pie Menus Edit",
    "author": "Cédric Lepiller",
    "version": (1, 0, 0),
    "blender": (2, 71, 4),
    "description": "Enable pie Menus Edit Mode",
    "category": "User Interface",}

# Define Class Vertex

class ClassVertex(bpy.types.Operator):
    bl_idname = "class.vertex"
    bl_label = "Class Vertex"
    
    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode != "EDIT":
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
        if bpy.ops.mesh.select_mode != "EDGE, FACE":
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') 
            
            return {'FINISHED'}

# Define Class Edge

class ClassEdge(bpy.types.Operator):
    bl_idname = "class.edge"
    bl_label = "Class Edge"
    
    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode != "EDIT":
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        if bpy.ops.mesh.select_mode != "VERT, FACE":
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') 
            
            return {'FINISHED'}
        
# Define Class Face

class ClassFace(bpy.types.Operator):
    bl_idname = "class.face"
    bl_label = "Class Face"
    
    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode != "EDIT":
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
        if bpy.ops.mesh.select_mode != "VERT, EDGE":
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE') 
            
            return {'FINISHED'}
        
        
# Pie Menu

class VIEW3D_PIE_edit(Menu):
    # label is displayed at the center of the pie menu.
    bl_label = "Select Mode"

    def draw(self, context):
        layout = self.layout

        pie = layout.menu_pie()
        pie.operator("class.vertex", text="Vertex", icon='VERTEXSEL')
        pie.operator("class.face", text="Face", icon='FACESEL')
        pie.operator("class.edge", text="Edge", icon='EDGESEL')
        
        pie.operator("object.editmode_toggle", text="Mode Object/Edit", icon='OBJECT_DATAMODE')

addon_keymaps = []

def register():
    bpy.utils.register_class(VIEW3D_PIE_edit)
    bpy.utils.register_class(ClassVertex)
    bpy.utils.register_class(ClassEdge)
    bpy.utils.register_class(ClassFace)
    
    wm = bpy.context.window_manager
    
    if wm.keyconfigs.addon:
       
        km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
        kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS', alt=True)
        kmi.properties.name = 'VIEW3D_PIE_edit'
        
 

        addon_keymaps.append(km)


def unregister():
    bpy.utils.unregister_class(VIEW3D_PIE_edit)
    bpy.utils.unregister_class(ClassVertex)
    bpy.utils.unregister_class(ClassEdge)
    bpy.utils.unregister_class(ClassFace)

    wm = bpy.context.window_manager

    if wm.keyconfigs.addon:
        for km in addon_keymaps:
            for kmi in km.keymap_items:
                km.keymap_items.remove(kmi)

            wm.keyconfigs.addon.keymaps.remove(km)

    # clear the list
    del addon_keymaps[:]

if __name__ == "__main__":
    register()

    bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_edit")



This is great !

I have made some changes as you can see.
Now we have other modes.


bl_info = {    "name": "Pie Edit Menu",
    "author": "Cédric Lepiller & DavideDozza",
    "version": (1, 0, 0),
    "blender": (2, 71, 4),
    "description": "Enable pie Menus Edit Mode",
    "category": "3D View",}
    
import bpy
from bpy.types import Menu    


# Define Class Object Mode


class ClassObject(bpy.types.Operator):
    bl_idname = "class.object"
    bl_label = "Class Object"
    
    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode == "OBJECT":
            bpy.ops.object.mode_set(mode="EDIT")
        else:
            bpy.ops.object.mode_set(mode="OBJECT")  
            
            
        return {'FINISHED'}




# Define Class Vertex


class ClassVertex(bpy.types.Operator):
    bl_idname = "class.vertex"
    bl_label = "Class Vertex"
    
    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode != "EDIT":
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
        if bpy.ops.mesh.select_mode != "EDGE, FACE":
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') 
            
            return {'FINISHED'}


# Define Class Edge


class ClassEdge(bpy.types.Operator):
    bl_idname = "class.edge"
    bl_label = "Class Edge"
    
    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode != "EDIT":
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        if bpy.ops.mesh.select_mode != "VERT, FACE":
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') 
            
            return {'FINISHED'}
        
# Define Class Face


class ClassFace(bpy.types.Operator):
    bl_idname = "class.face"
    bl_label = "Class Face"
    
    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode != "EDIT":
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
        if bpy.ops.mesh.select_mode != "VERT, EDGE":
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE') 
            
            return {'FINISHED'}
        
        
# Pie Menu


class VIEW3D_PIE_edit(Menu):
    # label is displayed at the center of the pie menu.
    bl_label = "Select Mode"


    def draw(self, context):
        layout = self.layout
           
        ob = context
        if ob.object.type == 'MESH':


            pie = layout.menu_pie()
            pie.operator("class.vertex", text="Vertex", icon='VERTEXSEL')
            pie.operator("class.face", text="Face", icon='FACESEL')
            pie.operator("class.edge", text="Edge", icon='EDGESEL')
            
            pie.operator("class.object", text="Edit/Object", icon='OBJECT_DATAMODE')
            
            pie.operator("paint.texture_paint_toggle", text="Texture Paint", icon='WPAINT_HLT')
            pie.operator("sculpt.sculptmode_toggle", text="Sculpt", icon='SCULPTMODE_HLT')
            pie.operator("paint.vertex_paint_toggle", text="Vertex Paint", icon='VPAINT_HLT')
            pie.operator("paint.weight_paint_toggle", text="Weight Paint", icon='WPAINT_HLT')
            
  
        elif ob.object.type == 'CURVE':
            
            pie = layout.menu_pie()
            pie.operator("object.editmode_toggle")
            
        elif ob.object.type == 'ARMATURE':
            
            pie = layout.menu_pie()
            pie.operator("object.editmode_toggle")  
        
        elif ob.object.type == 'FONT':
            
            pie = layout.menu_pie()
            pie.operator("object.editmode_toggle")      
        
        elif ob.object.type == 'SURFACE':
            
            pie = layout.menu_pie()
            pie.operator("object.editmode_toggle")  
        
        elif ob.object.type == 'ARMATURE':
            
            pie = layout.menu_pie()
            pie.operator("object.editmode_toggle")      
        
        elif ob.object.type == 'META':
            
            pie = layout.menu_pie()
            pie.operator("object.editmode_toggle")  
        
        elif ob.object.type == 'LATTICE':
            
            pie = layout.menu_pie()
            pie.operator("object.editmode_toggle")
            
        elif ob.object.type == 'ARMATURE':
            
            pie = layout.menu_pie()
            pie.operator("object.editmode_toggle")        
            
addon_keymaps = []


def register():
    bpy.utils.register_class(VIEW3D_PIE_edit)
    bpy.utils.register_class(ClassObject)
    bpy.utils.register_class(ClassVertex)
    bpy.utils.register_class(ClassEdge)
    bpy.utils.register_class(ClassFace)
    
    wm = bpy.context.window_manager
    
    if wm.keyconfigs.addon:
       
        km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
        kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS')
        kmi.properties.name = 'VIEW3D_PIE_edit'
        
 


        addon_keymaps.append(km)




def unregister():
    bpy.utils.unregister_class(VIEW3D_PIE_edit)
    bpy.utils.unregister_class(ClassObject)
    bpy.utils.unregister_class(ClassVertex)
    bpy.utils.unregister_class(ClassEdge)
    bpy.utils.unregister_class(ClassFace)


    wm = bpy.context.window_manager


    if wm.keyconfigs.addon:
        for km in addon_keymaps:
            for kmi in km.keymap_items:
                km.keymap_items.remove(kmi)


            wm.keyconfigs.addon.keymaps.remove(km)


    # clear the list
    del addon_keymaps[:]


if __name__ == "__main__":
    register()


#bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_edit")

I hope psy-fy will consider this, I think it’s faster than go in edit mod and choose component.

Excellent!

I put Tab alone to replace the current pie menu, alt + tab on windows change the software ^^

Oh, ok. So it is even better!

Last pie menu with Alt- Tab does not work on win 8.1
interfere with win keymap

will have to come back to the Tab only

how do u get the other menu for sculpt which keys works for this other pie menu ?

happy bl

I updated my code to works on object types, meta, surface etc.

I’m searching for the operators to add brushes on a pie menu, someone know how to find them ?

Also, I was wondering if we can add two or more pie menu in one addon with differents shortcuts ?
Normaly we can, I have made a test with a second class menu and a keymap with another shortcut, but, I had some errors.

any script example for post #49 with 25 buttons PM?

thanks

happy bl

Did you look in the python API for the operators? And post in 24 sebastian_k linked to a pie that he baked with multiple classes and keymaps.

RickyBlender, I think, it will not be possible to make this kinf of pie menu.

Thx Tardis, I look that :wink:

Ok, it’s really simple !!! Great !

Ran post #29 in text editor and the C keys works fine but not the R key !
why is it not working

Edit: got R key only in edit mode !

also I was told that all keys where converted to lower case
but this seem to work with upper caser letters how come ?

and where do u see the 2 level in there ?

thanks

pitiwazou,
Great work!
Maybe would be more sense grouping all the edit mode stuff (Vertex, Edge, Face) to the bottom side like this:

[ATTACH=CONFIG]330743[/ATTACH]

Attachments


Nope,I think it’s better to keep them on the cardinal cross.

You can modify the code for you if you want :wink: