ScriptSpot

Forum topic · Scripts Wanted

Script for instancing 'look-at' constraints

By james120479 · 2009-09-14

Description

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 (3)

stenionet · 2010-05-15

The script is working fine.
Thank you very much.

kevinala · 2009-09-16

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 · 2009-09-16

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.