#!BPY """ Name: 'LookAtCamera' Blender: 246 Group: 'Object' Tooltip: 'Make all selected objects that have a locked track constraint look at current camera' """ __author__ = ["Yorik van Havre"] __url__ = ("blender", "blenderartists", "http://yorik.orgfree.com") __version__ = "0" __bpydoc__ = """\ You know when you copy objects that are looking at the camera to another scene that already has a camera? They will go there, and bring their own camera!!! How gross!!! Now, with this script, you can delete the new unnecessary camera, select all the villain object, run the script, and they will redirect themselves to the right camera, the one that's active in the scene... You can also run the script on objects that are not looking at any camera, they will gain the same behaviour. """ # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # ***** END GPL LICENCE BLOCK ***** import Blender from Blender import * scn=Blender.Scene.GetCurrent() cam=scn.objects.camera obj=scn.objects.active oblist=scn.objects.selected def main(): #Ask if we look at active camera or active object cammode = Draw.PupMenu("Look at Active Camera|Look at Active Object") if (cammode == 2): target = obj else: target = cam print cammode print target for ob in oblist: found = False if len(ob.constraints) > 0: for const in ob.constraints: if const.type == Constraint.Type.LOCKTRACK: const[Constraint.Settings.TARGET] = target found = True if found == False: const = ob.constraints.append(Constraint.Type.LOCKTRACK) const[Constraint.Settings.TARGET] = target const[Constraint.Settings.TRACK] = 2 const[Constraint.Settings.LOCK] = 1 Blender.Window.RedrawAll() # This lets you import the script without running it if __name__ == '__main__': main()