Skip to content

Instantly share code, notes, and snippets.

@p2or
Last active May 21, 2023 18:01
Show Gist options
  • Save p2or/e0568d20cca23c8f5673 to your computer and use it in GitHub Desktop.
Save p2or/e0568d20cca23c8f5673 to your computer and use it in GitHub Desktop.
Blender - Toggle Simplify using Shift+Q, for http://blender.stackexchange.com/a/46864/3710 #Blender
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Toggle Simplify",
"description": "Toggle Simplify",
"author": "p2or",
"version": (0, 0, 3),
"blender": (2, 93, 0),
"tracker_url": "https://gist.github.com/p2or/e0568d20cca23c8f5673",
"location": "3D View",
"category": "3D View"
}
import bpy
# Operator
class ToggleSimplify(bpy.types.Operator):
"""Toggle Simplify"""
bl_idname = "view3d.toggle_simplify"
bl_label = "Toggle Simplify"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
context.scene.render.use_simplify = not context.scene.render.use_simplify
self.report({'INFO'}, "Simplify: {}"
.format(['Off','On'][context.scene.render.use_simplify]))
return {'FINISHED'}
addon_keymaps = []
# register
def register():
bpy.utils.register_class(ToggleSimplify)
# handle the keymap
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
km = wm.keyconfigs.addon.keymaps.new(name='3D View', space_type='VIEW_3D')
kmi = km.keymap_items.new(ToggleSimplify.bl_idname, type='Q', value='PRESS', shift=True)
addon_keymaps.append((km, kmi))
# unregister
def unregister():
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
bpy.utils.unregister_class(ToggleSimplify)
if __name__ == "__main__":
register()
@Vignatzy
Copy link

Vignatzy commented Oct 8, 2022

HI! Mty problem is : the addon works perfectly fine only on the project I was making, when I installed the add-on. It is all saved into my pereferences and in the default file. Meanwhile the shift q doesn't seem to work in other projects. The megssage "toggle ON/OFF" pops up, but there is nothing happening to the model, really.
Might be after 3.3.1 update? I'm not sure.

@p2or
Copy link
Author

p2or commented Oct 8, 2022

Hi @Vignatzy,

'Simplify' is only available in Cycles and I guess your default engine is Eevee. You might want to use the second script mentioned in my answer: http://blender.stackexchange.com/a/46864/3710. Does this help?

Cheers
Christian

@Vignatzy
Copy link

Vignatzy commented Oct 8, 2022

Hi @Vignatzy,

'Simplify' is only available in Cycles and I guess your default engine is Eevee. You might want to use the second script mentioned in my answer: http://blender.stackexchange.com/a/46864/3710. Does this help?

Cheers Christian

Dear Christian,

First of all, thank you for replying.
I only use Cycles, so I have it set by default. I resolved it. The problem was: Default simplify settings were not set to Max Subd:0 . That is why It wasn't really simplyfing anything. Every user needs to set Max SubD to 0 and save as a startup file.

Regards,
Ignacy

@p2or
Copy link
Author

p2or commented Oct 8, 2022

Hi @Vignatzy. No problem, glad it works! Regards, Christian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment