Add shape key automatically -help needed- (1/2 SOLVED)

Hi all: (noob question)

I need to do this for a project I’m working on but I’m not “ANY” good in python

Add a shape key at a certain frame and name it as the frame number itself

At the moment I -only- have this:


import bpy

add a new Shape Key

#bpy.ops.object.shape_key_add(from_mix=False)

select a Shape Key

#bpy.context.object.active_shape_key_index= 2

rename Shape Key (actual name / new name)

bpy.data.shape_keys[“Key”].key_blocks[“Key 1”].name = “25”

Think I need to have a variable that takes the frame number to further rename the recently added Shape Key

But I’m lost cause I can’t find how to retrieve the frame number

oh… well: hopefully have a button to press on to run the script

Any help ???

Thanks in advance

Don’t use the operator to add a shape key, then it will be a one-liner:

ob = bpy.context.object
frame = bpy.context.scene.frame_current

# Add shapekey with name equal to frame number
shape_key = ob.shape_key_add(name=str(frame), from_mix=False)

print(shape_key.name)

Thanks a lot CoDEmanX

It worked perfectly !!!

Now let me try to find how to add a button (before asking for help)

Ok … (Just in case you are interested)

How to put a button in Blender’s UI

I found some tutorials in Blender Cookie’s youtube channel

I will try and finally post the script here later

thanks