1
$\begingroup$

Let's say I have 2 objects: 1 empty and 1 cube. How could I create a "Copy Location" constraint for the empty, so it follows the cube's movement?

$\endgroup$

1 Answer 1

2
$\begingroup$
import bpy

scene = bpy.context.scene
obj = scene.objects['Cube']
empty = scene.objects['Empty']

constraint = obj.constraints.new('COPY_LOCATION')
constraint.target = empty
$\endgroup$
1
  • $\begingroup$ +1 for avoiding operators. This function-based approach is faster and more reliable. $\endgroup$
    – dr. Sybren
    Commented Jan 5, 2018 at 12:34

You must log in to answer this question.

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