19
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ Do you want these to have a target? $\endgroup$
    – iKlsR
    Commented Aug 14, 2013 at 15:57
  • $\begingroup$ Yes, I want them all to have the same target. Basically, I want them all to have the same constraint. $\endgroup$
    – Jason
    Commented Aug 14, 2013 at 16:14

3 Answers 3

29
$\begingroup$
  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.

$\endgroup$
6
  • 1
    $\begingroup$ 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! $\endgroup$
    – Jason
    Commented Aug 15, 2013 at 16:47
  • $\begingroup$ This does not appear to work in newer versions of Blender. $\endgroup$
    – J Sargent
    Commented Aug 24, 2017 at 19:31
  • $\begingroup$ @VRM I've just checked in the 2.79 release candidate and it still works. $\endgroup$ Commented Aug 25, 2017 at 12:57
  • 1
    $\begingroup$ I was using a different branch when testing, my bad $\endgroup$
    – J Sargent
    Commented Aug 25, 2017 at 14:34
  • $\begingroup$ This answer doesn`t work unfortunately, tested in Blender 3.0. $\endgroup$
    – Joehot200
    Commented Feb 14, 2022 at 7:29
5
$\begingroup$

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

  1. Enable the "Copy Attributes Menu" addon

  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.

$\endgroup$
1
  • $\begingroup$ This addon has restored the old inbuilt functionality of pre 2.5 versions. Very useful in my opinion. $\endgroup$ Commented Aug 14, 2013 at 19:48
5
$\begingroup$

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")
$\endgroup$
5
  • 1
    $\begingroup$ 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. $\endgroup$
    – Jason
    Commented Aug 14, 2013 at 16:13
  • $\begingroup$ @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. $\endgroup$
    – iKlsR
    Commented Aug 14, 2013 at 16:15
  • $\begingroup$ 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. $\endgroup$
    – Jason
    Commented Aug 15, 2013 at 16:45
  • 1
    $\begingroup$ 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. $\endgroup$
    – Jason
    Commented Aug 15, 2013 at 16:45
  • $\begingroup$ Happy to report that this solution STILL works as of Blender 2.83. Thanks! $\endgroup$ Commented Jul 15, 2020 at 15:05

You must log in to answer this question.

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