Paste Code
Paste Blends
Paste Images
# Add-on information
bl_info = {
"name" : "Reboot",
"author" : "(saidenka) meta-androcto",
"version" : (0,1),
"blender" : (2, 7),
"location" : "File Menu",
"description" : "Reboot Blender without save",
"warning" : "",
"wiki_url" : "",
"tracker_url" : "",
"category" : "System"
}


import bpy
import os, sys
import subprocess


class RestartBlender(bpy.types.Operator):
bl_idname = "wm.restart_blender"
bl_label = "Reboot Blender"
bl_description = "Blender Restart"
bl_options = {'REGISTER'}

def execute(self, context):
py = os.path.join(os.path.dirname(__file__), "console_toggle.py")
filepath = bpy.data.filepath
if (filepath != ""):
subprocess.Popen([sys.argv[0], filepath, '-P', py])
else:
subprocess.Popen([sys.argv[0],'-P', py])
bpy.ops.wm.quit_blender()
return {'FINISHED'}






def menu_func(self, context):
layout = self.layout
layout.separator()
layout.operator(RestartBlender.bl_idname, icon="PLUGIN")
layout.separator()




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


bpy.types.INFO_MT_file.prepend(menu_func)




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


bpy.types.INFO_MT_file.remove(menu_func)


if __name__ == "__main__":
register()
  1. # Add-on information
  2. bl_info = {
  3.         "name" : "Reboot",
  4.         "author" : "(saidenka) meta-androcto",
  5.         "version" : (0,1),
  6.         "blender" : (2, 7),
  7.         "location" : "File Menu",
  8.         "description" : "Reboot Blender without save",
  9.         "warning" : "",
  10.         "wiki_url" : "",
  11.         "tracker_url" : "",
  12.         "category" : "System"
  13. }
  14.  
  15.  
  16. import bpy
  17. import os, sys
  18. import subprocess
  19.  
  20.  
  21. class RestartBlender(bpy.types.Operator):
  22.         bl_idname = "wm.restart_blender"
  23.         bl_label = "Reboot Blender"
  24.         bl_description = "Blender Restart"
  25.         bl_options = {'REGISTER'}
  26.        
  27.         def execute(self, context):
  28.                 py = os.path.join(os.path.dirname(__file__), "console_toggle.py")
  29.                 filepath = bpy.data.filepath
  30.                 if (filepath != ""):
  31.                         subprocess.Popen([sys.argv[0], filepath, '-P', py])
  32.                 else:
  33.                         subprocess.Popen([sys.argv[0],'-P', py])
  34.                 bpy.ops.wm.quit_blender()
  35.                 return {'FINISHED'}
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. def menu_func(self, context):
  43.     layout = self.layout
  44.     layout.separator()
  45.     layout.operator(RestartBlender.bl_idname, icon="PLUGIN")
  46.     layout.separator()
  47.  
  48.  
  49.  
  50.  
  51. def register():
  52.     bpy.utils.register_module(__name__)
  53.  
  54.  
  55.     bpy.types.INFO_MT_file.prepend(menu_func)
  56.  
  57.  
  58.  
  59.  
  60. def unregister():
  61.     bpy.utils.register_module(__name__)
  62.  
  63.  
  64.     bpy.types.INFO_MT_file.remove(menu_func)
  65.  
  66.  
  67. if __name__ == "__main__":
  68.     register()
go to heaven