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?
- With the objects selected, add the desired constraint to the active object.
- From the 3D View header menu choose Object > Constraints > Copy Constraints to Selected Objects.
All the objects will now have the same constraint.
This method doesn't require an add-on to work.
I discovered how to do this using an add-on.
Enable the "Copy Attributes Menu" addon
Use Ctrl+C to activate the menu
Choose "Copy Selected Constraints"
This doesn't let you modify the constraints, though, or remove them.
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")