I want to be able to "commit" (or "realize") all Shape Key deformations on multiple selected objects using Python.

By this I mean: create a New Shape From Mix, then delete all other shapes, then finally delete the mix result shape, leaving the selected objects altered but with no more shape key data.

Here's what I've got so far:

import bpy
context = bpy.context
scene = context.scene
sel_objs = context.selected_objects

for each selected object...

New Shape From Mix


Get the number of shape key indices.

Iterate through and remove all except the last (leaving the last one as the true shape):


Then remove the final remaining one as well (for cleanup).

I'm unclear on some of the details when putting this all together. Any help appreciated.


1 Answer 1


This is how I've done this in one project:

import bpy
context = bpy.context
objs = context.selected_objects

for ob in objs:
    ob.hide_viewport = False  # should be visible
    if ob.data.shape_keys:
         ob.shape_key_add(name='CombinedKeys', from_mix=True)
         for shapeKey in ob.data.shape_keys.key_blocks:

Avoid using ops, because you have to set context override every time, it is quite difficult because you have to guess that values have to be overridden

  • $\begingroup$ Thank you! It seems you're not specifying the order of key deletion. Is that because the newly added "CombinedKeys" is indexed last, and therefore automatically gets deleted last? $\endgroup$
    – Mentalist
    Commented May 24, 2022 at 10:04
  • $\begingroup$ Yes. you are right. $\endgroup$
    – Crantisz
    Commented May 24, 2022 at 10:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .