With this simple script you can "track" selected vertex. Script make an empty object that follows selected vertex position. This script work also with armature animation and that's the main reason why I made this simple experimental script.

About & Preview

I face some problems with my experimental CoinRig while trying "Bake Action" to my object and move data to After Effects. I do not get this to work with "Bake Action" or neither Collada format methods, becase rig's x,y,z doesn't work properly at this case. So I want to achieve other method to get my position data from that object. More precisely in this case I just want to select couple vertices and use their position data. So, I made this simple script for that process and it works! There could be already similar scripts, but I want to make my own and learn some more Blender Python API.

Script

And here is that simple "FollowVertexPos.py" script that I have used in this case.

import bpy

# Set active scene and object
activeScene = bpy.context.scene
currentObj = bpy.context.active_object

# Set custom empty name
emptyName = 'VertexTarget'

# Get selected vertex index number
vertexIndex = [i.index for i in bpy.context.active_object.data.vertices if i.select]

# Create empty
if emptyName not in bpy.data.objects:
bpy.ops.object.empty_add(type='PLAIN_AXES')
bpy.context.active_object.name = emptyName
targetEmpty = bpy.data.objects.get(emptyName)

# Run only if mesh is selected
if currentObj.type == 'MESH':

# Loop current frame range
for frame in range(activeScene.frame_end + 1):

# Set active frame
activeScene.frame_set(frame)

# Make meshdata
meshdata = currentObj.to_mesh( scene=activeScene, apply_modifiers=True, settings='PREVIEW' )

# Loop meshdata vertices
for vertex in meshdata.vertices:

# Selected vertex only
if vertex.index == vertexIndex[0]:

# Calculate world coords for the empty
newCoord = meshdata.vertices[vertex.index].co
newCoord = currentObj.matrix_world * newCoord

# Set new location for empty and make keyframe
targetEmpty.location = newCoord
targetEmpty.keyframe_insert(data_path='location', frame=(frame))

# Remove meshdata data
bpy.data.meshes.remove(meshdata)
else:
print('SELECT MESH OBJECT!')

Download this script here:

Download “Blender Script FollowVertexPos.zip”

FollowVertexPos.zip – Downloaded 1254 times – 928.00 B

How To Use Script

  1. Load Script to Blender.
  2. Select one vertex from object.
  3. Run script.
  4. Thats it. It makes empty object automatically for you and keyframe position to every frame.

You can select only one vertex with this script version. It's not big deal to make it possible to use with multi selection, but I do not need it in this case.

If you make your own custom script based this one or find this script useful, please drop a comment below...

Links that I found useful in this case:

http://blenderscripting.blogspot.fi/2011/07/how-to-set-activeobject-via-python.htmlhttp://blenderscripting.blogspot.fi/2011/07/getting-index-of-currently-selected.htmlhttp://blenderscripting.blogspot.fi/2011/05/blender-25-python-printing-vertex.htmlhttps://sites.google.com/site/satishgoda/blender/learningblender25/introduction-to-blender-python-api