# Why doesn't my Custom Pie Menu work after restarting Blender?

So I would like to create custom pie menus. I have followed the tutorial by Sebastian Kónig that seems quite popular... but it's as if he leaves out the portion that tells you how to save it and have it work when you restart Blender. Being an artist and total non-coder I'm not even sure where to start figuring out why it's not working after a restart. Could someone please explain to me what I need to do to make this work? or perhaps point me to the section of the manual that covers this? here is the tutorial I followed... https://vimeo.com/103321600
do I need to check Register? this seems to be greyed out sometimes.. but not others. Do I need to save the script in a specific location? Any help would be greatly appreciated :) cheers

import bpy

# spawn an edit mode selection pie (run while object is in edit mode to get a valid output)

# label is displayed at the center of the pie menu.
bl_idname = "mesh.beddallpie"

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

# operator_enum will just spread all available options
# for the type enum of the operator on the pie
pie.operator_enum("mesh.select_mode", "type")
pie.operator("mesh.noise")
pie.operator("mesh.vertices_smooth")
pie.operator("transform.vertex_random")

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

wm = bpy.context.window_manager
kmi = km.keymap_items.new("wm.call_menu_pie", "E", "PRESS", shift=True, ctrl=True).properties.name="mesh.beddallpie"

def unregister():
bpy.utils.unregister_class(VIEW3D_PIE_template)

if __name__ == "__main__":
register()



I originally didn't include the code as the code works... what doesn't work is having it available once i restart Blender. Everything works fine until i restart... then it's like the script never existed. I'm missing the knowledge that will make the script still work when I restart Blender, and for a non-coder this info seems rather elusive.

• If you're asking about code then, ideally, you need to show that code. Use the edit link below your question to update your question with your code. – Ray Mairlot Mar 19 '17 at 11:55
• Done. Sorry if it's not in the right format... non-coder here :( – Beddall Mar 19 '17 at 12:58

You haven't told Blender yet how to load this code on Startup. Two methods are available:

• using the register checkbox you mentioned

While the second method might seem more daunting in the beginning, it is the way more flexible way. The first method requires you to rename the Text data block (the tooltip of the register checkbox tells you this) to have a .py extension:

Only when the extension is .py as in the screenshot, registering is available. It then doesn't matter if the Text datablock is a part of the Blend file, or if it is an external text. You can use register and it should load and register when you open a file that contains it. However, that means every time to add that Text datablock to your file, check register, save and reload. It's not exactly nice to work like this.

The Add-on workflow is much more flexible: All you need to do with your code itself is to add an information dictionary that tells Blender hey, I'm an Add-on, offer to load me. It looks like this:

import bpy

#    add relevant code to tell Blender that this is an addon
bl_info = {
"version": (1, 0, 0),
"blender": (2, 75, 0),
"category": "User Interface"
}


This tells Blender what name the Add-on has, who wrote it, where to show it in the Add-on manager, the version of the Add-on and most important the minimum Blender version needed to run it. The rest of your code is identical to what you already had:

#    spawn an edit mode selection pie (run while object is in edit mode to get a valid output)
#    label is displayed at the center of the pie menu.
bl_idname = "mesh.beddallpie"

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

#    operator_enum will just spread all available options
#    for the type enum of the operator on the pie
pie.operator_enum("mesh.select_mode", "type")
pie.operator("mesh.noise")
pie.operator("mesh.vertices_smooth")
pie.operator("transform.vertex_random")

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

wm = bpy.context.window_manager
kmi = km.keymap_items.new("wm.call_menu_pie", "E", "PRESS", shift = True, ctrl = True).properties.name = "mesh.beddallpie"

def unregister():
bpy.utils.unregister_class(VIEW3D_PIE_template)

if __name__ == "__main__":
register()



When you save this file (again using a .py extension) into your Add-on folder (see the file path locations here: https://docs.blender.org/manual/en/dev/getting_started/installing/configuration/directories.html), you can - after restarting Blender - enable it in the Add-on manager:

after enabling the checkbox, make sure to also click Save User Settings to always have it enabled on startup. Now, when you continue to work on the Add-on, you can edit this .py file directly. After saving, you can hit F8 to ask Blender to reload all Add-ons, or restart Blender.