I have a large number of objects, and I wish to add a Track to constraint to each object. When I select the group of them and then add the constraint, it is added to only the active object, of course. How can I add the constraint to all selected objects?
You could also just loop through the selected objects and apply the contraint to each one.
The line with
objs.target is an example of how to set the target object. In this example, I assume that all the selected objects will have an Empty as the target.
import bpy context = bpy.context for x in bpy.context.selected_objects: objs = x.constraints.new(type='TRACK_TO') objs.target = context.scene.objects.get("Empty")