Baking my own pie menus or changing the default ones in 2.72

Hello everybody.

I have no idea of scripting and coding. Nevertheless I would like to bake my own pie menus in blender or change the existing ones so that they fit to my needs.

I watch Sebastian König’s tutorial about that issue at the moment but have a couple of questions.

Example: Changing the pie menu for the viewport shading or baking a new one in official 2.72 (shortcut: ‘Z’). OS: Windows 7 Ultimate 64 bit.

If you hover over buttons in the blender ui the python expressions of the functions are displayed and if you rightclick you can choose ‘edit source’ and the appropriate script opens in the texteditor.

However this does not work with the menu for the viewport shading in the 3D view header e.g. because there is no ‘edit source’ menu item.

So what I want to know now:

What are the expressions that determine the items in menus like this (viewport shading e.g.) and where do I find them?

How can I use these items to build a pie menu script?

How can I change the default pie menus that come with 2.72?

I took a look at the script of the addon ‘pie menus official’ but I didn’t find anything in it that seems to contain expressions concerning menus like I mention above e.g. a list with ‘Bounding Box’, ‘Material’, ‘Texture’ and so on.

viewport shading is an enum property and there are functions to add enum properties to panels etc. The code of these layout methods is written in C. Most of the 3d view header is actually written in C, although it could be written in Python except for the layer widget.

To add such a property to a layout, simply use layout.prop(…)

Ok, I’ll try to concretize what I would like to do.

The picture in the attachement shows the Viewport Shading Pie Menu as it is on the left and the way I would like to change it to on the right.

I would be very grateful if anyone could tell me a step by step description how I should proceed to reach such kind of result based on the example shown in the picture.

Which are the folders and files that contain the expressions which build the pie menu?

Can I simply change orders of expressions to change the positions of buttons?

Where do I find the mentioned C-expressions that define the 3d View Header menu items?

I have already been searching quite a while now but I have really no idea.

Attachments


Ok, I’ll try to concretize what I would like to do.

The picture in the attachement shows the Viewport Shading Pie Menu as it is on the left and the way I would like to change it to on the right.

I would be very grateful if anyone could tell me a step by step description how I should proceed to reach such kind of result based on the example shown in the picture.

Which are the folders and files that contain the expressions which build the pie menu?

Can I simply change orders of expressions to change the positions of buttons?

Where do I find the mentioned C-expressions that define the 3d View Header menu items?

I have already been searching quite a while now but I have really no idea.

Attachments


Which are the folders and files that contain the expressions which build the pie menu?

This is basically the code:
https://developer.blender.org/rB028fd29eeb092b6ed0625ed4d59b8100ae69596f

The order of enum properties is defined somewhere, and there’s a defined order for pie menus, and you have no control over the order unless it’s your own enum property (so you could change the order of items to change the order in the pie menu) - unless you workaround layout.prop() and add wm.context_set_*() operators to the menu for every enum item individually, so you can control the order of these operators (move the lines around in the code to change order in pie).

A user on blendpolis.de draw my attention to this pie menu script. It contains exactly the expressons I was looking for:

[TABLE=“class: highlight tab-size-8 js-file-line-container”]

#Pie Shading

class PieShadingView(Menu):

bl_idname = “pie.shadingview”

bl_label = “Pie Shading”

def draw(self, context):

layout = self.layout

pie = layout.menu_pie()

#4 - LEFT

pie.operator(“object.shadingvariable”, text=“Material”, icon=‘MATERIAL’).variable = ‘MATERIAL’

#6 - RIGHT

pie.operator(“object.shadingvariable”, text=“Wireframe”, icon=‘WIRE’).variable = ‘WIREFRAME’

#2 - BOTTOM

pie.operator(“object.shadingvariable”, text=“Texture”, icon=‘TEXTURE_SHADED’).variable = ‘TEXTURED’

#8 - TOP

pie.operator(“object.shadingvariable”, text=“Solid”, icon=‘SOLID’).variable = ‘SOLID’

#7 - TOP - LEFT

pie.operator(“object.shadingvariable”, text=“Bounding box”, icon=‘BBOX’).variable = ‘BOUNDBOX’

#9 - TOP - RIGHT

pie.operator(“object.shadingvariable”, text=“Render”, icon=‘SMOOTH’).variable = ‘RENDERED’

#1 - BOTTOM - LEFT

pie.operator(“shading.smooth”, text=“Shade Smooth”, icon=‘SOLID’)

#3 - BOTTOM - RIGHT

pie.operator(“shading.flat”, text=“Shade Flat”, icon=‘MESH_ICOSPHERE’)

[/TABLE]
I only had to regroup the lines to achieve the result I wanted to.

Thank you very much for your help. There surely is a lot of stuff to mess about with but for now I consider this matter closed.

For any further questions be sure I will be here again. :smiley: