# zTrack - by Roland Hess 2005 # Wrote it for myself - hope it helps you # # Orients selected objects (probably cards) # toward the object named "Camera" # but only rotates their Z axis, so # the cards remain upright. Great for # trees and forests. from Blender import * import math obloop=Object.GetSelected() camera = Object.Get("Camera") cameraloc=camera.getLocation() for plane in obloop: planeloc = plane.getLocation() dx=cameraloc[0] - planeloc[0] dy=cameraloc[1] - planeloc[1] planeZ=math.atan(dx/dy) planerot = plane.getEuler() print planerot[0],planerot[1],planeZ plane.setEuler(planerot[0],planerot[1],-planeZ)