0
$\begingroup$

I encounter the issue that in my pie the RMB Pie stays open when releasing keys and mouse while the LMB Pie closes instantly I release a key or mouse buttong.

I have no idea what triggers this.

Anybody could give me a tip?

I added my Pie code here:

bl_info = {
    "name": "Claas_Pie_Menus",
    "author": "Claas Eicke Kuhnen",
    "version": (0, 2, 0),
    "blender": (2, 73, 1),
    "description": "Custom Pie Menus",
    "category": "3D View",}

import bpy, os
from bpy.types import Menu, Header   
from bpy.props import IntProperty, FloatProperty, BoolProperty
import bmesh
from mathutils import *
import math
from bpy.types import Menu, Panel, UIList

#################
#    Commands   #               
#################



#Calculate Normal Mesh
class CalculateNormal(bpy.types.Operator):  
    bl_idname = "calculate.normal"  
    bl_label = "Calculate Normal"  
    bl_options = {'REGISTER', 'UNDO'}


    def execute(self, context):
        if context.active_object:
            if(context.mode == 'EDIT_MESH'):
                bpy.ops.mesh.select_all(action = 'SELECT')
                bpy.ops.mesh.normals_make_consistent(inside=False)
                bpy.ops.mesh.select_all(action = 'DESELECT')
            else:
                bpy.ops.object.editmode_toggle()
                bpy.ops.mesh.select_all(action = 'SELECT')
                bpy.ops.mesh.normals_make_consistent(inside=False)
                bpy.ops.mesh.select_all(action = 'DESELECT')
                bpy.ops.object.editmode_toggle()
        return {'FINISHED'} 

#Set Origin to 3D cursor
class SetOrigin(bpy.types.Operator):
    bl_idname = "set.origin"
    bl_label = "Set Mesh Origin"
    bl_options = {'REGISTER'}

    def execute(self, context):
        if bpy.context.mode != 'EDIT_MESH':
            bpy.ops.object.editmode_toggle()
            return{'FINISHED'}
        bpy.ops.view3d.snap_cursor_to_selected()
        bpy.ops.object.editmode_toggle()
        bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
        bpy.ops.object.editmode_toggle()
        return{'FINISHED'}


######################
#     Pie Menus      #               
######################

# Pie RMB Viewport Shading 
class PieRMB(Menu):
    bl_idname = "pie.rmb"
    bl_label = "Viewport Shading "

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

        if context.active_object:
            if(context.mode == 'EDIT_MESH'):

                mesh = context.active_object.data
                scene = context.scene
                #4
                f = pie.operator("wm.context_set_enum", icon='WIRE', text='Wires')
                f.data_path='space_data.viewport_shade'
                f.value = 'WIREFRAME'
                #6
                pie.operator("mesh.reveal", text="Show Mesh")
                #2
                box = pie.split().box().column()
                row = box.row()
                box.operator("MESH_OT_faces_shade_smooth", text="Mesh Smooth")
                box.operator("MESH_OT_faces_shade_flat", text="Mesh Flat")
                box.separator()
                box.operator("calculate.normal")
                box.operator("mesh.flip_normals")
                box.separator()
                row = box.row()
                row.prop(mesh, "show_normal_face", text="Face Normal", icon='FACESEL')
                row.prop(scene.tool_settings, "normal_size", text="Size")
                box.separator()
                row = box.row(align=True)
                row.prop(mesh, "show_extra_edge_length", text="Edge Length")
                row.prop(mesh, "show_extra_face_angle", text="Face Angle")
                box.separator()
                row = box.row()
                row.prop(mesh, "use_auto_smooth")
                row.prop(mesh, "auto_smooth_angle", text="Angle")
                #8
                f = pie.operator("wm.context_set_enum", icon='SMOOTH', text='Rendered')
                f.data_path='space_data.viewport_shade'
                f.value = 'RENDERED'
                #7
                f = pie.operator("wm.context_set_enum", icon='SOLID', text='Solid')
                f.data_path='space_data.viewport_shade'
                f.value = 'SOLID'
                #9
                f = pie.operator("wm.context_set_enum", icon='MATERIAL', text='Material')
                f.data_path='space_data.viewport_shade'
                f.value = 'MATERIAL'  
                #1
                pie.operator("mesh.hide", text="Hide Mesh Selected").unselected=False
                #box = pie.split().column()
                #row = box.row()
                #box.operator("mesh.hide", text="Hide Mesh Selected").unselected=False
                #box.operator("mesh.hide", text="Hide Mesh Unselected").unselected=True
                #box.operator("mesh.reveal", text="Show Mesh")
                #3
                pie.operator("mesh.hide", text="Hide Mesh Unselected").unselected=True

            else:

                mesh = context.active_object.data
                scene = context.scene   

                #4 - LEFT
                f = pie.operator("wm.context_set_enum", icon='WIRE', text='Wires')
                f.data_path='space_data.viewport_shade'
                f.value = 'WIREFRAME'
                #6 - RIGHT
                pie.operator("object.hide_view_clear", text="Show Object")                
                #2 - BOTTOM
                box = pie.split().box().column()
                row = box.row()
                box.operator("OBJECT_OT_shade_smooth", text="Object Smooth")
                box.operator("OBJECT_OT_shade_flat", text="Object Flat")
                box.separator()
                box.operator("calculate.normal", text="Calculate Normals")
                box.separator()
                row = box.row()
                row.prop(mesh, "use_auto_smooth")
                row.prop(mesh, "auto_smooth_angle", text="Angle")
                #8 - TOP
                f = pie.operator("wm.context_set_enum", icon='SMOOTH', text='Rendered')
                f.data_path='space_data.viewport_shade'
                f.value = 'RENDERED'
                #7 - TOP - LEFT
                f = pie.operator("wm.context_set_enum", icon='SOLID', text='Solid')
                f.data_path='space_data.viewport_shade'
                f.value = 'SOLID' 
                #9 - TOP - RIGHT
                f = pie.operator("wm.context_set_enum", icon='MATERIAL', text='Material')
                f.data_path='space_data.viewport_shade'
                f.value = 'MATERIAL'
                #1 - BOTTOM - LEFT
                pie.operator("object.hide_view_set", text="Hide Object Selected")
                #3 - BOTTOM - RIGHT
                pie.operator("object.hide_view_set", text="Hide Object Unselected").unselected=True



        #4 - LEFT
        #6 - RIGHT
        #2 - BOTTOM
        #8 - TOP
        #7 - TOP - LEFT 
        #9 - TOP - RIGHT
        #1 - BOTTOM - LEFT
        #3 - BOTTOM - RIGHT



addon_keymaps = []


class PieLMB(Menu):
    bl_idname = "pie.lmb"
    bl_label = "Edit"

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


        if(context.mode == 'EDIT_MESH'):

            mesh = context.active_object.data
            scene = context.scene

        #4 - LEFT
            pie.operator("mesh.extrude_region_move", text="Extrude")
        #6 - RIGHT
            pie.operator("mesh.bevel")
        #2 - BOTTOM
            box = pie.split().box().column()
            row = box.row()
            box.operator("mesh.remove_doubles")
            box.operator("mesh.merge", text="Merge")
            box.operator("mesh.knife_tool", text="Knife")
            box.operator("mesh.vert_connect")
            box.operator("mesh.fill_grid", text="Grid Fill")
            box.operator("mesh.inset", text="Insert Face")
            box.operator("mesh.offset_edge_loops_slide", text="Offset LoopCut")
            box.separator()
            box.operator("mesh.intersect_boolean", text="Boolean Union").operation='UNION'
            box.operator("mesh.intersect_boolean", text="Boolean Difference").operation='DIFFERENCE'
            box.operator("mesh.intersect_boolean", text="Boolean Intersect").operation='INTERSECT'
            box.separator()
            box.operator("set.origin", text="Set Origin to 3D Cursor")  
        #8 - TOP
            pie.operator("mesh.bridge_edge_loops", text="Bridge")            
        #7 - TOP - LEFT 
            pie.operator("mesh.edge_face_add", text="Fill")
        #9 - TOP - RIGHT
            pie.operator("mesh.loopcut_slide", text="Loop Cut")
        #1 - BOTTOM - LEFT
            pie.operator("wm.call_menu_pie", text="Edge Menu", icon='PLUS').name = "EdgeMenu"     
        #3 - BOTTOM - RIGHT  
            pie.operator("screen.redo_last")


        else:

            mesh = context.active_object.data
            scene = context.scene  

            pie.operator("object.origin_set").type='ORIGIN_CURSOR' 

        #4 - LEFT
        #6 - RIGHT
        #2 - BOTTOM
        #8 - TOP
        #7 - TOP - LEFT 
        #9 - TOP - RIGHT
        #1 - BOTTOM - LEFT
        #3 - BOTTOM - RIGHT

addon_keymaps = []


class EdgeMenu(Menu):
    bl_label = "More"

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

        pie = layout.menu_pie()
        #4 - LEFT
        pie.operator("transform.edge_crease", text="Crease Weight")
        #6 - RIGHT
        pie.operator("mesh.mark_sharp", text="Mark Shrap")
        #2 - BOTTOM
        pie.operator("mesh.mark_sharp", text="Clear Sharp").clear=True
        #8 - TOP
        pie.operator("mesh.mark_seam", text="Mark Seam").clear=False
        #7 - TOP - LEFT 
        pie.operator("transform.edge_bevelweight", text="Bevel Weight")
        #9 - TOP - RIGHT
        pie.operator("mesh.mark_seam", text="Clear Seam").clear=True
        #1 - BOTTOM - LEFT
        pie = pie.row()
        pie.label('')
        pie = layout.menu_pie()
        #3 - BOTTOM - RIGHT
        pie = pie.row()
        pie.label('')
        pie = layout.menu_pie()
        addon_keymaps = []  

def register():
    bpy.utils.register_module(__name__)


# Keympa Config   

    wm = bpy.context.window_manager

    if wm.keyconfigs.addon:

        #Viewport Shade
        km = wm.keyconfigs.addon.keymaps.new(name = 'Object Non-modal')
        kmi = km.keymap_items.new('wm.call_menu_pie', "RIGHTMOUSE", "PRESS", shift=True, ctrl=True)
        kmi.properties.name = "pie.rmb"

        addon_keymaps.append(km)

        #Edit
        km = wm.keyconfigs.addon.keymaps.new(name = 'Object Non-modal')
        kmi = km.keymap_items.new('wm.call_menu_pie', "LEFTMOUSE", "PRESS", shift=True, ctrl=True)
        kmi.properties.name = "pie.lmb"

        addon_keymaps.append(km)

# Register / Unregister Classes
def unregister():
    bpy.utils.unregister_module(__name__)


    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()
$\endgroup$
2
$\begingroup$

Pies have a lifetime and behavior determined by your cursor movements and keyboard events. Pies all behave the same way, however the way you may be using them may be different.

Basic Functions

Tapping: If you tap the key, which is to say you press and release quickly, the pie will stay open until you cancel out or choose an operation. You can move your cursor anywhere you please without making a selection. You may also use the numpad to make a selection (each entry position corresponds to its number position around 5. For example, 8 is top, 4 is left, etc.). Quick selection keys apply, like in the vertical-style menus (mode select pie: O for object mode, E for edit mode, etc.).

Holding: If you hold the key, you can move the cursor in a direction and release the key to select an operation in the pie. As long as you hold the key, you can move your cursor anywhere you please without making a selection. Press RMB or ESC to cancel the pie. Numpad and quick select keys apply here, too.

Special Functions

Holding: While holding, you have a few other options than just to hold and release the key. While holding the key, you may also return the cursor to the starting point, inside the circle at the center of the pie. This will not select any option in the pie. Releasing the key inside the circle to close the pie without making a selection.

Autoselect: The user preferences allow you to enable autoselection, which means the pie will automatically confirm a selection based on the cursor position outside the center circle.

User preferences -> Interface -> Pie Menus -> Confirm Threshold

This setting describes how far away from the center circle your cursor must be before a selection is automatically made. The distance is visually described with a partial circle that follows the cursor. You can still use LMB to confirm and RMB and ESC to cancel. With autoselect enabled, you are still able to tap the key to open the pie without making a selection. Numpad and quick select keys also apply here.

Subpies: If you have a pie entry that spawns another pie menu, you will need to confirm with LMB to make a selection in the subpie. Autoselect will allow you to hold the key during the entire pie navigation. Numpad and quick select keys also apply here.

$\endgroup$
  • $\begingroup$ I reread your post, but I am not able to figure out how to make a Pie menu that I spawn via PRESS LMB stay while with every other mouse Button the Pie will stay. Any idea? $\endgroup$ – Claas Kuhnen Jan 12 '16 at 17:15
  • $\begingroup$ I'm not sure, either. I haven't tried out your code yet, but I will do that and see what I can do. I would think that's a property of using LMB to spawn the menu when it's also used to confirm. There's an option in user prefs -> editing that confirms selection on mouse release. Try playing with that and see if that helps. $\endgroup$ – Italic_ Jan 13 '16 at 3:25
  • $\begingroup$ Yeah I get the same feeling - if true than I have to say good bye to LMB. $\endgroup$ – Claas Kuhnen Jan 13 '16 at 3:27

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.