Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/dk.py
Created September 9, 2013 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/6502398 to your computer and use it in GitHub Desktop.
Save zeffii/6502398 to your computer and use it in GitHub Desktop.
import bpy
# Data from Sketchup.
cam = lambda: None
cam.eye = (240.719, -236.069, 102.276)
cam.target = (-285.372, 553.004, -82.0446)
cam.fov = 35.0
# Create empty to target.
bpy.ops.object.empty_add(location=cam.target)
target = bpy.context.object
# Create camera.
bpy.ops.object.camera_add(location=cam.eye)
bpy.context.object.data.lens = cam.fov
# Configure camera to track the empty.
constraint = bpy.context.object.constraints.new("TRACK_TO")
constraint.target = target
constraint.track_axis = "TRACK_NEGATIVE_Z"
constraint.up_axis = "UP_Y"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment