I am very new to blender and python . i want to make python script which can animate the vertex point of any object (let's example bpy.data.obajects['Cube'])

import bpy

obj = bpy.data.objects["Cube"]
obj.shape_key_add(name="Basis", from_mix=False)

block = obj.shape_key_add(name="1", from_mix=False)  

block.value = 0.0
block.data[0].co = (0,0,0)
block.keyframe_insert(data_path='mute', frame= 0,index=-1)

block.value = 1.0
block.data[0].co = (1,1,1)
block.keyframe_insert(data_path='mute', frame= 50,index=-1)

the above code steps works when i set it up by GUI blender , but In script it just set keyframes but no actual animation occur on play

  • $\begingroup$ Well when I press play it does actually "animate", it changes the cube to the object in the screenshot: imgur.com/a/0G0EGHT $\endgroup$
    – WhatAMesh
    Aug 12 '18 at 20:10
  • $\begingroup$ @WhatAMesh , Well the image you are showing is just final state of that animation and that's what was happening with me too . It instantly change to next keyframe but what I need is smooth transition between two frames (like an analog not digital , exactly) $\endgroup$ Aug 13 '18 at 2:58
import bpy

cell = bpy.data.objects['Cube']
bpy.context.scene.objects.active = cell

basis_key = cell.shape_key_add('basis')
basis_key.keyframe_insert('value', frame=0)

deform_key = cell.shape_key_add()
deform_key.data[0].co = ( 5 , 5 , 5)

deform_key.value = 0.0
deform_key.keyframe_insert('value', frame = 0)

deform_key.value = 1.0
deform_key.keyframe_insert('value', frame = 200)

the main difference in your script is that you set your data_path as "mute" , so just replace data_path="value" then it will work fine


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.