Module Object
[frames | no frames]

Module Object

The Blender.Object submodule

New:

Object

This module provides access to the Objects 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.
Property This property gives access to object property data in Blender.

Function Summary
  Duplicate(mesh, surface, curve, text, metaball, armature, lamp, material, texture, ipo)
Duplicate selected objects on visible layers from Blenders current scene, de-selecting the currently visible, selected objects and making a copy where all new objects are selected.
  Get(name)
Get the Object from Blender.
  GetSelected()
Get the user selection.
  New(type, name)
Creates a new Object.

Function Details

Duplicate(mesh=0, surface=0, curve=0, text=0, metaball=0, armature=0, lamp=0, material=0, texture=0, ipo=0)

Duplicate selected objects on visible layers from Blenders current scene, de-selecting the currently visible, selected objects and making a copy where all new objects are selected. By default no data linked to the object is duplicated; use the keyword arguments to change this. Object.GetSelected() will return the list of objects resulting from duplication.
Parameters:
mesh - When non-zero, mesh object data will be duplicated with the objects.
           (type=bool)
surface - When non-zero, surface object data will be duplicated with the objects.
           (type=bool)
curve - When non-zero, curve object data will be duplicated with the objects.
           (type=bool)
text - When non-zero, text object data will be duplicated with the objects.
           (type=bool)
metaball - When non-zero, metaball object data will be duplicated with the objects.
           (type=bool)
armature - When non-zero, armature object data will be duplicated with the objects.
           (type=bool)
lamp - When non-zero, lamp object data will be duplicated with the objects.
           (type=bool)
material - When non-zero, materials used by the object or its object data will be duplicated with the objects.
           (type=bool)
texture - When non-zero, texture data used by the object's materials will be duplicated with the objects.
           (type=bool)
ipo -

When non-zero, Ipo data linked to the object will be duplicated with the objects.

Example:

The example below creates duplicates the active object 10 times and moves each object 1.0 on the X axis:
 import Blender

 scn = Scene.GetCurrent()
 activeObject = scn.getActiveObject()
 
 # Unselect all
 for ob in Blender.Object.GetSelected():
     ob.sel = 0
 activeObject.sel = 1
 
 for x in xrange(10):
     Blender.Object.Duplicate() # Duplicate linked
     activeObject = scn.getActiveObject()
     activeObject.LocX += 1
 Blender.Redraw()

           (type=bool)

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

Note: Get will return objects from all scenes. Most user tools should only operate on objects from the current scene - Blender.Scene.GetCurrent().getChildren()

GetSelected()

Get the user selection. 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

Notes:

  • The active object will always be the first object in the list (if selected).
  • The user selection is made up of selected objects from Blenders current scene only.
  • The user selection is limited to objects on visible layers, if the users last active 3d view is in localview then the selection will be limited to the objects in that localview.

New(type, name='type')

Creates a new Object.
Parameters:
type - The Object type: 'Armature', 'Camera', 'Curve', 'Lamp', 'Lattice', 'Mball', 'Mesh', 'Surf' or 'Empty'.
           (type=string)
name - The name of the object. By default, the name will be the same as the object type. If the name is alredy in use, this new object will have a number at the end of the name.
           (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.1 on Thu Jul 13 16:50:06 2006 http://epydoc.sf.net