0
$\begingroup$

I have a data generation process in Blender 4.2 that generates an ordered point cloud (vertex only mesh) and I want to interpolate between the 2 generations with Shapekeys. I import them into Blender as separate objects. I can not figure out how to get the 2nd object as a key in the first Object's shape keys.

The order of the vertices needs to be preserved.

I have a function which can copy the vertices. I wonder if anyone could help with the Python API to edit the 2nd key vertices to copy over the vertex positions eg. target.data.vertices[k].co = src.data.vertices[k].co but where target is the shape-key keypoint.

$\endgroup$

1 Answer 1

0
$\begingroup$
import bpy

def apply_shape_key(target_obj, src_obj):
    verts = target_obj.data.vertices

    sk_basis = target_obj.shape_key_add(name='Basis')
    sk_basis.interpolation = 'KEY_LINEAR'
    target_obj.data.shape_keys.use_relative = False

    sk = target_obj.shape_key_add(name='Deform')
    sk.interpolation = 'KEY_LINEAR'

    # position each vert
    for i in range(len(verts)):
        sk.data[i].co = src_obj.data.vertices[i].co
        
target_obj = bpy.data.objects.get('obj_a')
src_obj = bpy.data.objects.get('obj_b')
apply_shape_key(target_obj, src_obj)
$\endgroup$
1
  • $\begingroup$ Hi, thanks for the post. This site is not a regular forum, answers should be substantial, stand on their own, and thoroughly explain the solution and required steps. One liners and short tips and code only posts rarely make for a good answer. If you can, edit your post and provide some more details about the procedure and how it works, perhaps add a few images illustrating some steps and final result. See How to write a good answer?, otherwise it may be converted to a comment. $\endgroup$ Commented Nov 18 at 22:06

You must log in to answer this question.

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