Module Object
[frames | no frames]

Module Object

The Blender.Object submodule

This module provides access to the Object Data in Blender.

Example:
 import Blender
 scene = Blender.Scene.getCurrent ()   # get the current scene
 ob = Blender.Object.New ('Camera')    # make camera object
 cam = Blender.Camera.New ('ortho')    # make ortho camera data object
 ob.link (cam)                         # link camera data with the object
 scene.link (ob)                       # link the object into the scene
 ob.setLocation (0.0, -5.0, 1.0)       # position the object in the scene

 Blender.Redraw()                      # redraw the scene to show the updates.

Classes
Object This object gives access to generic data from all objects in Blender.

Function Summary
  Get(name)
Get the Object from Blender.
  GetSelected()
Get the selected objects from Blender.
  New(type, name)
Creates a new Object.

Function Details

Get(name=None)

Get the Object from Blender.
Parameters:
name - The name of the requested Object.
           (type=string)
Returns:
It depends on the 'name' parameter:
  • (name): The Object with the given name;
  • (): A list with all Objects in the current scene.

Example 1:

The example below works on the default scene. The script returns the plane object and prints the location of the plane:
 import Blender

 object = Blender.Object.Get ('plane')
 print object.getLocation()

Example 2:

The example below works on the default scene. The script returns all objects in the scene and prints the list of object names:
 import Blender

 objects = Blender.Object.Get ()
 print objects

GetSelected()

Get the selected objects from Blender. If no objects are selected, an empty list will be returned.
Returns:

A list of all selected Objects in the current scene.

Example:

The example below works on the default scene. Select one or more objects and the script will print the selected objects:
 import Blender

 objects = Blender.Object.GetSelected ()
 print objects

New(type, name='type')

Creates a new Object.
Parameters:
type - The Object type: 'Armature', 'Camera', 'Curve', 'Lamp', 'Mesh' or 'Empty'.
           (type=string)
name - The name of the object. By default, the name will be the same as the object type.
           (type=string)
Returns:

The created Object.

Example:

The example below creates a new Lamp object and puts it at the default location (0, 0, 0) in the current scene:
  import Blender
  
  object = Blender.Object.New ('Lamp')
  lamp = Blender.Lamp.New ('Spot')
  object.link (lamp)
  scene = Blender.Scene.getCurrent ()
  scene.link (object)

  Blender.Redraw()

Generated by Epydoc 2.0 on Wed May 12 22:11:02 2004 http://epydoc.sf.net