Script for instancing 'look-at' constraints

Does anyone know if a script exists that will allow me to modify the look-at constraints for multipe objects at one time? The problem i am having is that i need to apply 'look-at' constraints to a large selection of objects, which i can do in one go but then i need to change the lookAt axis but can only do this one object at a time which will take a fair while. I want to be able to change for many objects in one click.

Does anyone know if this is possible?

Ta
James

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
stenionet's picture

The script is working

The script is working fine.
Thank you very much.

kevinala's picture

If you want what I think you

If you want what I think you want, you just need a simple loop. Select all your objects and run this:

for i = 1 to selection.count do
(
selection[i].rotation.controller[2].target_axis = #
)

All you need to do is replace the # with 0 for X, 1 for Y, and 2 for Z.

If you want to turn on flip, add this inside the loop:

selection[i].rotation.controller[2].target_axisFlip = true

This is assuming your lookAt constraint got added in the standard spot as the 2nd controller in the rotation list.

To see the wording for the other options to change in the lookAt, use this in the listener:

show selection[1].rotation.controller[2]

kevinala's picture

If you want I can write this

If you want I can write this into an actual tool or macro, but if it is sufficient as is that is good.

As is it has no error checking of course, so if any selected object doesn't have a rotation list with a lookAt constraint it will error out.

Just drop a post if this is all you need, or if you would want a ui and I'll put it together when I get home.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.