O'Reilly logo

Blender 2.49 Scripting by Michel J. Anders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding different types of object from a script

Adding other types of objects is, in many cases, just as straightforward as adding our text object. If we want our scene to be populated in a way that enabled us to render it, we would have to add a camera and a lamp to make things visible. Adding a camera to the same scene could be done like this (assuming we still have a reference to our active scene in the scn variable):

from Blender import Camera
cam = Camera.New() # creates new camera data
ob = scn.objects.new(cam) # adds a new camera object
scn.setCurrentCamera(ob) # makes this camera active

Note that the Camera object is again different from the actual camera data. A Camera object holds camera-specific data, such as viewing angle, and a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required