I have a set of shape keys on an object. I’m creating a new one in my script from one of them via “bpy.ops.object.shape_key_add(from_mix=True)” (Shape Key from Mix) Now, I need to get to the newly created shape key, define it and do something with it, but have absolutely no idea how to get to it.
Any help would be wildly appreciated. Thank you in advance.
obj = bpy.data.objects['myObject'] #get your object
activeKey = obj.shape_key_add('myKey', True) #add a new shapekey, name it, use from_mix, and store it in a variable
… then you can access the newly created shape key’s properties via the variable.
In Python, the last item in a list has the index -1, and in Blender an added shape key will be the active shape key immediately after it is added.
bpy.context.active_object.data.shape_keys.key_blocks[-1]
or
bpy.context.active_object.active_shape_key