# Add object constraint to a number of selected objects

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?

• Do you want these to have a target? – iKlsR Aug 14 '13 at 15:57
• Yes, I want them all to have the same target. Basically, I want them all to have the same constraint. – Jason Aug 14 '13 at 16:14

1. With the objects selected, add the desired constraint to the active object.
2. 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.

• That is exactly what I was looking for! I can't believe I never noticed this menu before. I also see it has a Clear Object Constraints command, which I now know is a thing! – Jason Aug 15 '13 at 16:47
• This does not appear to work in newer versions of Blender. – VRM Aug 24 '17 at 19:31
• @VRM I've just checked in the 2.79 release candidate and it still works. – Ray Mairlot Aug 25 '17 at 12:57
• I was using a different branch when testing, my bad – VRM Aug 25 '17 at 14:34

I discovered how to do this using an add-on.

2. Use Ctrl+C to activate the menu

3. Choose "Copy Selected Constraints"

This doesn't let you modify the constraints, though, or remove them.

• This addon has restored the old inbuilt functionality of pre 2.5 versions. Very useful in my opinion. – Haunt_House Aug 14 '13 at 19:48

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")

• I like this answer because it gives me more flexibility than my discovered answer, but it's also a lot more complex than just using an add-on. – Jason Aug 14 '13 at 16:13
• @Jason it is very simple to use actually, just drop it into the text editor and run it as you need it. If need be, you can also put it into a small addon and map a shortcut to it. Also, based on your comment on the question, if you want to add a new object with the same constraint and target, just select it and run the script again. – iKlsR Aug 14 '13 at 16:15
• I'm comfortable using Python to manipulate Blender, but this seems like a task that someone might want to do who was a relative newcomer to Blender. For newcomers, Python can be intimidating. For complicated tasks that are relatively uncommon, I think a Python solution is fine, but for a task that is simple or common, I would rather there be a UI solution. – Jason Aug 15 '13 at 16:45
• That being said, your solution did show me how to create a new constraint using Python, which is something that I was having trouble with. – Jason Aug 15 '13 at 16:45