3
$\begingroup$

I am scripting a script that parents an empty to a vertex of a mesh. When I change the parent type to VERTEX, it gives me the error:

enum 'VERTEX' not found in ('OBJECT')

Here is my code in context:

empt = bpy.data.objects.new("Empty", None)
empt.parent = meshobj
empt.parent_type = 'VERTEX'
empt.parent_vertices[0] = meshobj.data.vertices[1]
$\endgroup$

1 Answer 1

3
$\begingroup$

For me, your script does not break at the parent_type setting line, but one line later. The parent_vertices array does not expect an object to be given, but an integer: it is the index number of the vertex that needs to be passed on. This slightly modified version of your script works for me in both 2.76 and 2.78:

import bpy

meshobj=bpy.context.object

empt = bpy.data.objects.new("Empty", None)
empt.parent = meshobj
empt.parent_type = 'VERTEX'

# only pass on the index, not the vertex object
empt.parent_vertices[0] = 1

# add the object to the scene so we see what's happening
bpy.context.scene.objects.link(empt)
$\endgroup$

You must log in to answer this question.

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