2
$\begingroup$

I'm doing this pie menu to help me texturing without the T panel, I'm new in all that and i need some help:

Is there a way to split the right column in 2 or 3 or display it in horizontal?

every time I release the left button of the mouse the pie dissapear, is there a way to keep open the pie and close only when the key is released ? or only close the pie with the esc button ... ?

the color menu works in 2.79 and 2.8 but it doesn't display in 2.8

I would like to add the new brushes from the new T panel from blender 2.8 and the smooth stroke button, even if it has a shortcut that would be usefull to me, but I have no idea how

enter image description here

enter image description here

bl_info = {
    "name": "Pie_Quick_Color_Brush",
        "description": "Single line explaining what this script exactly does.",
    "author": "John Doe, Jane Doe",
    "version": (1, 0),
    "blender": (2, 65, 0),
    "location": "View3D > Add > Mesh",
    "warning": "", # used for warning icon and text in addons panel
    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
                "Scripts/My_Script",
    "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
    "support": "COMMUNITY",
    "category": "Add Mesh"
    }



import bpy
from bpy.types import Menu

class VIEW3D_PIE_COLORS(Menu):

    bl_label = "Color Mode"
    bl_idname = "mesh.mypie"

    def draw(self, context):
        ts = context.tool_settings
        ups = ts.unified_paint_settings
        ptr = ups if ups.use_unified_color else ts.image_paint.brush
        toolsettings = context.tool_settings
        ipaint = toolsettings.image_paint

        pie = self.layout.menu_pie()
        pie.operator_enum("mesh.paint_mode", "type")
        box = pie.box()
        box.template_color_picker(ptr, "color", value_slider=True)

        box.template_palette(ts.image_paint, "palette", color=True)
        box = pie.box() 

        box.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
        box.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
        box.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
        box.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
        box.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
        box.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'


        box = pie.box()        
        box.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
        box.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
        box.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)


def register():
    bpy.utils.register_class(VIEW3D_PIE_COLORS)


def unregister():

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

if __name__ == "__main__":
    register()

if you wanna try it, download the code, name it Pie_Quick_Color_Brush.py and install it just like all the addons, the script doesn't assign a hotkey so you have to do it manually, just add one in 3d View > Image Paint

identifier of operator : wm.call_menu_pie

name : mesh.mypie

I've find a solution for, is there a way to keep open the pie and close only when the key is released? and the color menu works in 2.79 and 2.8 but it doesn't display in 2.8, only works for the color selector and isn't exactly what I want, but works

enter image description here

bl_info = {
    "name": "Pie_Quick_Color_Brush",
        "description": "Single line explaining what this script exactly does.",
    "author": "John Doe, Jane Doe",
    "version": (1, 0),
    "blender": (2, 65, 0),
    "location": "View3D > Add > Mesh",
    "warning": "", # used for warning icon and text in addons panel
    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
                "Scripts/My_Script",
    "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
    "support": "COMMUNITY",
    "category": "Add Mesh"
    }



import bpy
from bpy.types import Menu
# spawn an edit mode selection pie (run while object is in edit mode to get a valid output)
class VIEW3D_PIE_COLORS(Menu):
    # label is displayed at the center of the pie menu.
    bl_label = "Color Mode"
    bl_idname = "mesh.mypie"

    def draw(self, context):
        ts = context.tool_settings
        ups = ts.unified_paint_settings
        ptr = ups if ups.use_unified_color else ts.image_paint.brush
        toolsettings = context.tool_settings
        ipaint = toolsettings.image_paint

        pie = self.layout.menu_pie()
        pie.operator_enum("mesh.paint_mode", "type")
        box = pie.box()


        box.template_palette(ts.image_paint, "palette", color=True)
        box.prop(ptr, 'color')
        box = pie.box() 

        box.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
        box.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
        box.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
        box.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
        box.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
        box.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'


        box = pie.box()        
        box.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
        box.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
        box.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)


def register():
    bpy.utils.register_class(VIEW3D_PIE_COLORS)


def unregister():

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

if __name__ == "__main__":
    register()
$\endgroup$
2
$\begingroup$

Firstly blender v2.80 is currently in early development and not everything is working, so leave that until it is ready for release.

We are not able to alter the behaviour of a pie menu, it will always go away after we click on an item like any menu is expected to do. To keep your things constantly visible you need to make a panel instead of a pie menu. A panel still offers a benefit as you can show just the items you want all in one place, you can even place it on the opposite side to the toolbar (although you can also make the toolbar switch sides).

You can have your addon assign a hotkey to your menu by setting the idname as wm.call_menu_pie and the name as mesh.mypie - which is the bl_idname of your menu class.

Pie menus use the same layout techniques as panels, to show items in a row, you ask for a row() from the layout.

box = pie.box()
row = box.row()
row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
row = box.row()
row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'

To learn how the brushes menu is setup (and most other UI bits), right click on it and choose edit source to have the script open in blenders text editor and the cursor on the line used.

This menu is a little trickier than others, you need to have your pie menu a subclass of UnifiedPaintPanel.

import bpy
from bpy.types import Menu
from bl_ui.properties_paint_common import UnifiedPaintPanel

class VIEW3D_PIE_COLORS(Menu, UnifiedPaintPanel):

    bl_label = "Color Mode"
    bl_idname = "mesh.mypie"

Then in draw() add

settings = self.paint_settings(context)
box = pie.box()
box.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)

pie menu using rows and brush menu

You could look at the grease pencil settings pie menu as an example of several layout techniques.

$\endgroup$
  • $\begingroup$ works great, ty 4 all $\endgroup$ – nwytg May 10 '18 at 8:45

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.