import bpy
FileName=""
FileMinValue=10001
FileMaxValue=10100
obj_path = "C:/objtest"
obj_name=str(FileMinValue)+".obj"
index=0
MaxFrame=FileMaxValue-FileMinValue
objfull=obj_path+"/"+obj_name
bpy.ops.wm.obj_import(filepath=objfull, directory=obj_path)
FirstObj = bpy.context.active_object
bpy.ops.object.join()
shape_key = FirstObj.shape_key_add(name="MyShapeKey"+str(index), from_mix=False)
for i in range(FileMinValue,FileMaxValue):
index+=1
obj_name=str(i)+".obj"
objfull=obj_path+"/"+obj_name
print("fullname:"+objfull)
bpy.ops.wm.obj_import(filepath=objfull, directory=obj_path)
SecondObj = bpy.context.active_object
bpy.ops.object.join()
bpy.context.view_layer.objects.active = FirstObj
shape_key = FirstObj.shape_key_add(name="MyShapeKey"+str(index), from_mix=False)
for j, v in enumerate(SecondObj.data.vertices):
shape_key.data[j].co = v.co
for k in range(0,MaxFrame):
if k==index:
shape_key.value = 1.0
shape_key.keyframe_insert(data_path='value', frame=k)
else:
shape_key.value = 0
shape_key.keyframe_insert(data_path='value', frame=k)
bpy.data.objects.remove(SecondObj, do_unlink=True)