I want to create “if” conditional statements that ask if the user is in vertex, edge or face selection mode while in edit mode, such that I can create a hotkey to bypass the call menu that arises when you go to delete a selection of mesh. Can you do this?
Bonus question: Does anyone know if there is an operator or setting I can use to change the state of the “editing cage mode” of a subdivision surface modifier? Thanks.
Note that there is FACE_EDGE mode and there can be multiple select modes at the same time. You could do more checks and handle them in a meaningful way.
Overwrite the default X shortcut with an operator that does the above checks to replace the builtin delete menu.
Thanks. How would I implement that global check into a conditional? I’m still pretty new to Python. I’ve got one hotkey set up to delete objects in object mode, to bypass Blender’s call menu and get straight on to the deleting, and I’d like to use that same key to do the selection type sensitive deleting while in edit mode. I keep getting one working or the other. I could set up separate operators for them but that would not be ideal. Thanks.
ob = bpy.context.object
if ob is None or ob.type != 'MESH':
# do nothing
pass
elif ob.mode == 'EDIT':
bpy.ops.mesh.delete(...)
else:
bpy.ops.object.delete(...)
Another way would be to poll-check:
if bpy.ops.mesh.delete.poll():
# only if we have a mesh!
elif bpy.ops.object.delete.poll():
# delete object if possible, otherwise do nothing
Thanks, I had tried using the global check as an if, but managed to forget I needed a “:” at the end of my if statement. Two many programing languages swirling around in my head.:spin: All works now. I have now successfully injected my “X” key with amphetamines lol. Once again, thanks so much.