Post #266: Mighty Pea:

πŸ“‹ Metadata

  • Author: roaoao
  • Date: 2016-08-04 06:21:05
  • Type: answer
  • Quality Score: 9/10
  • Reply to: post_00265

🏷️ Tags

macro hotkeys advanced solved

  • Macro Editor
  • Python Scripting

πŸ’¬ Content

Mighty Pea:

Would it be possible to set it up so tools that only work in a certain mode can automatically enable said mode?
For example, flip normals in object mode would automatically go to edit mode, or deleting a modifier (which can’t be done in edit mode) would take you into object mode.
Possibly it would even take you back to the mode you were in before, so it wouldn’t interrupt your workflow at all?

Yes its possible. You need to modify your command using this template:

obj_mode = C.active_object.mode; O.object.mode_set(mode='REQUIRED_OBJECT_MODE'); YOUR_COMMAND; O.object.mode_set(mode=obj_mode)

Flip Normals:

obj_mode = C.active_object.mode; O.object.mode_set(mode='EDIT'); O.mesh.flip_normals(); O.object.mode_set(mode=obj_mode)

Delete Modifier:

obj_mode = C.active_object.mode; O.object.mode_set(mode='OBJECT'); O.object.modifier_remove(modifier="Subsurf"); O.object.mode_set(mode=obj_mode)

You can find other object modes here.


πŸ”— View on Blender Artists