Hi, this simple addon is very useful for addons devs.
we tire of restarting Blender to ensure the changed code works.
basically this addon will shutdown & restart blender automagically.
Note that it will not save anything. it will simply shut down & restart Blender.
Huge thanks to saidenka Blender-Scramble-Addon
as I found this function whilst translating his tools.
Enjoy.
# 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()
3 Likes
Bayesian
(Bayesian)
April 26, 2015, 1:26am
2
I sort of do the same with the command line option --python my_script.py
Spirou4D
(Spirou4D)
April 26, 2015, 3:50am
3
Thks @Meta-Androcto , always a good idea!
Needed absolutely when you code…Congrats.
ctdabomb
(ctdabomb)
April 26, 2015, 5:10am
4
Sigh, Why did I think this said Robot Blender Addon? :rolleyes: I must be stupid today.
ctdabomb,
that’s a whole different addon.
mkbreuer
(mkbreuer)
January 28, 2019, 7:58pm
6
Hy Meta-Androcto!
Do you plan a 2.80 revival for the reboot addon?
This would be very handy!
I tried fix it by myself: it works, but the exit quit menu pops up after some changes in the text editor?
# Add-on information
bl_info = {
"name" : "Reboot",
"author" : "(saidenka) meta-androcto",
"version" : (0,1),
"blender" : (2, 80, 0),
"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__), "wm.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_class(RestartBlender)
bpy.types.TOPBAR_MT_file.prepend(menu_func)
def unregister():
bpy.utils.unregister_class(RestartBlender)
bpy.types.TOPBAR_MT_file.remove(menu_func)
if __name__ == "__main__":
register()
hi, if you turn off prompt for quit in user prefs it should be ok.
I added prompt for quit button in ui not sure if it’s useful.
# Add-on information
bl_info = {
"name" : "Reboot",
"author" : "(saidenka) meta-androcto",
"version" : (0,1),
"blender" : (2, 80, 0),
"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__), "wm.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()
prefs = context.preferences
view = prefs.view
layout.prop(view, "use_quit_dialog")
def register():
bpy.utils.register_class(RestartBlender)
bpy.types.TOPBAR_MT_file.prepend(menu_func)
def unregister():
bpy.utils.unregister_class(RestartBlender)
bpy.types.TOPBAR_MT_file.remove(menu_func)
if __name__ == "__main__":
register()
not ideal but works
1 Like
Dogway
January 6, 2020, 1:08pm
9
Updated to current API, it works but the quit dialog is being ignored.
# Add-on information
bl_info = {
"name": "Reboot",
"author": "(saidenka) meta-androcto",
"version": (0, 1),
"blender": (2, 82, 0),
"location": "File Menu",
"description": "Reboot Blender without save",
"warning": "",
"wiki_url": "https://blenderartists.org/t/reboot-blender-addon/640465",
"tracker_url": "",
"category": "System"
}
import bpy
import os, sys
import subprocess
class BLENDER_OT_Restart(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__), "wm.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_draw(self, context):
layout = self.layout
layout.separator()
layout.operator("wm.restart_blender", text="Restart", icon='PLUGIN')
layout.separator()
prefs = bpy.context.preferences
view = prefs.view
layout.prop(view, "use_save_prompt")
def register():
bpy.utils.register_class(BLENDER_OT_Restart)
bpy.types.TOPBAR_MT_file.append(menu_draw)
def unregister():
bpy.utils.unregister_class(BLENDER_OT_Restart)
bpy.types.TOPBAR_MT_file.remove(menu_draw)
if __name__ == "__main__":
register()
I’ll be keeping these and other mods in my Github .
4 Likes
Very useful thank you very much
thanks. I’ll take a look at what you did.
derksenyan
(Max Derksen )
June 22, 2021, 8:10pm
12
how should the console open? but this is not happening. Blender 2.93
OSError: Python file “C:\Users\mrtma\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\wm.console_toggle.py” could not be opened: No such file or directory
Hi, sorry if this is a bit late, I made an updated addon that automatically opens the console again:
reboot_blender.zip (2.9 KB)
(It’s multifile now, so you need to install the whole zip)
3 Likes
IPv6
(IPv6)
August 11, 2021, 10:49am
14
we tire of restarting Blender to ensure the changed code works.
There is another way to do it - Install “VS Code” and add Blender Development addon to it after installation (jacqueslucke.blender-development). It is a full-featured text/code editor that connects directly to blender. Works with all Blenders (up to date) and python code refresh is like a hit of a button. You also get terminal output and may use debugger for python execution (although didn`t use debugger by myself)
3 Likes
derksenyan
(Max Derksen )
August 11, 2021, 11:47pm
15
Thank you very much, this addon makes my life easier)
ZeroDean
(Zero Dean)
February 6, 2024, 8:05pm
16
Man, this option was so handy when it worked (THANK YOU ).
Just tested in Blender 4.02 Windows and it appears not to.
ulf3000
(Alexander Mehler)
February 9, 2024, 10:06pm
17
dogway’s version above works for me even on 4.1
ZeroDean
(Zero Dean)
February 10, 2024, 12:46am
18
Interesting. I just downloaded the above version to make sure I didn’t have some other version installed.
It shuts down Blender 4.02 for me… it just doesn’t reboot it. And doesn’t ask to save either. I remember when it did.