Module Object :: Class Object
[frames | no frames]

Class Object


The Object object

This object gives access to generic data from all objects in Blender.
Method Summary
  addProperty(property)
Add a property to object.
  addScriptLink(text, event)
Add a new script link to this Object.
  buildParts()
Recomputes the particle system.
  clearIpo()
Unlinks the ipo from this object.
bool clearScriptLinks()
Delete all this Object's script links.
  clearTrack(mode, fast)
Make this Object not track another anymore.
  clrParent(mode, fast)
Clears parent object.
  copyAllPropertiesTo(object)
Copies all properties from one object to another.
Py_Action getAction()
Returns an action if one is associated with this object (only useful for armature types).
PyList getAllProperties()
Return a list of properties from this object.
list of 8 (x,y,z) float coordinate vectors getBoundBox()
Returns the bounding box of this object.
Object type specific getData()
Returns the Datablock object containing the object's data.
A vector triple getDeltaLocation()
Returns the object's delta location in a list (x, y, z)
Integer getDrawMode()
Returns the object draw mode.
Integer getDrawType()
Returns the object draw type
Py_Euler getEuler()
Returns the object's rotation as Euler rotation vector (rotX, rotY, rotZ).
Py_Matrix getInverseMatrix()
Returns the object's inverse matrix.
Ipo getIpo()
Returns the Ipo associated to this object or None if there's no linked ipo.
  getLocation()
Returns the object's location (x, y, z).
list of Material Objects getMaterials(what)
Returns a list of materials assigned to the object.
Py_Matrix getMatrix(space)
Returns the object matrix.
  getName()
Returns the name of the object
Object getParent()
Returns the object's parent object.
Property object getProperty(name)
Return a properties from this object based on name.
list getScriptLinks(event)
Get a list with this Object's script links of type 'event'.
  getSize()
Returns the object's size.
  getTimeOffset()
Returns the time offset of the object's animation.
Object getTracked()
Returns the object's tracked object.
  getType()
Returns the type of the object.
Boolean isSelected()
Returns the objects selection state as a boolean value True or False.
  link(object)
Links Object with data provided in the argument.
  makeDisplayList()
Updates this object's display list.
  makeParent(objects, noninverse, fast)
Makes the object the parent of the objects provided in the argument which must be a list of valid Objects.
  makeTrack(tracked, fast)
Make this Object track another.
  removeAllProperties()
Removes all properties from an object.
  removeProperty(property)
Remove a property from an object.
  select(boolean)
Sets the object's selection state.
  setDeltaLocation(delta_location)
Sets the object's delta location which must be a vector triple.
  setDrawMode(drawmode)
Sets the object's drawing mode.
  setDrawType(drawtype)
Sets the object's drawing type.
  setEuler(euler)
Sets the object's rotation according to the specified Euler angles.
  setIpo(ipo)
Links an ipo to this object.
  setLocation(x, y, z)
Sets the object's location.
  setMaterials(materials)
Sets the materials.
  setMatrix(matrix)
Sets the object's matrix and updates it's tranformation.
  setName(name)
Sets the name of the object.
  setSize(x, y, z)
Sets the object's size.
  setTimeOffset(timeOffset)
Sets the time offset of the object's animation.
  shareFrom(object)
Link data of object specified in the argument with self.

Class Variable Summary
  colbits: The Material usage mask.
  data: The data of the object.
  dloc: The delta (X,Y,Z) location coordinates of the object (vector).
  dLocX: The delta X location coordinate of the object.
  dLocY: The delta Y location coordinate of the object.
  dLocZ: The delta Z location coordinate of the object.
  drawMode: The object's drawing mode used.
  drawType: The object's drawing type used.
  drot: The delta (X,Y,Z) rotation angles (in radians) of the object (vector).
  dRotX: The delta X rotation angle (in radians) of the object.
  dRotY: The delta Y rotation angle (in radians) of the object.
  dRotZ: The delta Z rotation angle (in radians) of the object.
  dsize: The delta (X,Y,Z) size of the object.
  dSizeX: The delta X size of the object.
  dSizeY: The delta Y size of the object.
  dSizeZ: The delta Z size of the object.
  EffX: The X effector coordinate of the object.
  EffY: The Y effector coordinate of the object.
  EffZ: The Z effector coordinate of the object.
  ipo: The ipo data associated with the object.
  Layer: The object layer.
  loc: The (X,Y,Z) location coordinates of the object (vector).
  LocX: The X location coordinate of the object.
  LocY: The Y location coordinate of the object.
  LocZ: The Z location coordinate of the object.
  mat: The matrix of the object relative to its parent.
  matrix: The matrix of the object relative to its parent.
  matrixLocal: The matrix of the object relative to its parent.
  matrixWorld: The matrix of the object in world space.
  name: The name of the object.
  parent: The parent object of the object.
  rot: The (X,Y,Z) rotation angles (in radians) of the object (vector).
  RotX: The X rotation angle (in radians) of the object.
  RotY: The Y rotation angle (in radians) of the object.
  RotZ: The Z rotation angle (in radians) of the object.
  sel: The selection state of the object, 1/0.
  size: The (X,Y,Z) size of the object (vector).
  SizeX: The X size of the object.
  SizeY: The Y size of the object.
  SizeZ: The Z size of the object.
  track: The object tracking this object.

Method Details

addProperty(property)

Add a property to object.
Parameters:
property - property object to add to object.
           (type=Property object)

Warning: A property object can be added only once to an object' you must remove the property from an object to add it elsewhere.

addScriptLink(text, event)

Add a new script link to this Object.
Parameters:
text - the name of an existing Blender Text.
           (type=string)
event - "FrameChanged" or "Redraw".
           (type=string)

buildParts()

Recomputes the particle system. This method only applies to an Object of the type Effect.

clearIpo()

Unlinks the ipo from this object.
Returns:
True if there was an ipo linked or False otherwise.

clearScriptLinks()

Delete all this Object's script links.
Returns:
0 if some internal problem occurred or 1 if successful.
           (type=bool)

clearTrack(mode=0, fast=0)

Make this Object not track another anymore.
Parameters:
mode - if nonzero the matrix transformation used for tracking is kept.
           (type=int (bool))
fast - if zero, the scene hierarchy is updated automatically. If you set 'fast' to a nonzero value, don't forget to update the scene yourself (see Scene.Scene.update).
           (type=int (bool))

clrParent(mode=0, fast=0)

Clears parent object.
Parameters:
mode - A mode flag. If mode flag is 2, then the object transform will be kept. Any other value, or no value at all will update the object transform.
           (type=Integer)
fast - If the value is 0, the scene hierarchy will not be updated. Any other value, or no value at all will update the scene hierarchy.
           (type=Integer)

copyAllPropertiesTo(object)

Copies all properties from one object to another.
Parameters:
object - Object that will recieve the properties.
           (type=Object object)

getAction()

Returns an action if one is associated with this object (only useful for armature types).
Returns:
a python action.
           (type=Py_Action)

getAllProperties()

Return a list of properties from this object.
Returns:
List of Property objects.
           (type=PyList)

getBoundBox()

Returns the bounding box of this object. This works for meshes (out of edit mode) and curves.
Returns:
The coordinates of the 8 corners of the bounding box.
           (type=list of 8 (x,y,z) float coordinate vectors)

getData()

Returns the Datablock object containing the object's data. For example the Mesh, Lamp or the Camera.
Returns:
Depending on the type of the Object, it returns a specific object for the data requested.
           (type=Object type specific)

getDeltaLocation()

Returns the object's delta location in a list (x, y, z)
Returns:
(x, y, z)
           (type=A vector triple)

getDrawMode()

Returns the object draw mode.
Returns:
a sum of the following:
  • 2 - axis
  • 4 - texspace
  • 8 - drawname
  • 16 - drawimage
  • 32 - drawwire

           (type=Integer)

getDrawType()

Returns the object draw type
Returns:
One of the following:
  • 1 - Bounding box
  • 2 - Wire
  • 3 - Solid
  • 4 - Shaded
  • 5 - Textured

           (type=Integer)

getEuler()

Returns the object's rotation as Euler rotation vector (rotX, rotY, rotZ). Angles are in radians.
Returns:
A python euler
           (type=Py_Euler)

getInverseMatrix()

Returns the object's inverse matrix.
Returns:
A python matrix 4x4
           (type=Py_Matrix)

getIpo()

Returns the Ipo associated to this object or None if there's no linked ipo.
Returns:
the wrapped ipo or None.
           (type=Ipo)

getLocation()

Returns the object's location (x, y, z).
Returns:

(x, y, z)

Example:

The example below works on the default scene. It retrieves all objects in the scene and prints the name and location of each object:
 import Blender

 objects = Blender.Object.Get()

 for obj in objects:
     print obj.getName()
     print obj.getLocation()

getMaterials(what=0)

Returns a list of materials assigned to the object.
Parameters:
what - if nonzero, empty slots will be returned as None's instead of being ignored (default way). See NMesh.NMesh.getMaterials.
           (type=int)
Returns:
list of Material Objects assigned to the object.
           (type=list of Material Objects)

getMatrix(space='localspace')

Returns the object matrix. Use getMatrix() or getMatrix('localspace') to get the matrix relative to the objects parent. Somtimes the absolute matrix of the object is required (taking into account vertex parents, tracking and ipo's) in this case use getMatrix('worldspace')
Parameters:
space - possible values are:
  • localspace (default)
  • worldspace
Returns the object matrix.
           (type=string. Values are:)
Returns:
a python matrix 4x4
           (type=Py_Matrix)

getName()

Returns the name of the object
Returns:

The name of the object

Example:

The example below works on the default scene. It retrieves all objects in the scene and prints the name of each object:
 import Blender

 objects = Blender.Object.Get()

 for obj in objects:
     print obj.getName()

getParent()

Returns the object's parent object.
Returns:
The parent object of the object. If not available, None will be returned.
           (type=Object)

getProperty(name)

Return a properties from this object based on name.
Parameters:
name - the name of the property to get.
           (type=string)
Returns:
The first property that matches name.
           (type=Property object)

getScriptLinks(event)

Get a list with this Object's script links of type 'event'.
Parameters:
event - "FrameChanged" or "Redraw".
           (type=string)
Returns:
a list with Blender Text names (the script links of the given 'event' type) or None if there are no script links at all.
           (type=list)

getSize()

Returns the object's size.
Returns:
(SizeX, SizeY, SizeZ)

getTimeOffset()

Returns the time offset of the object's animation.
Returns:
TimeOffset

getTracked()

Returns the object's tracked object.
Returns:
The tracked object of the object. If not available, None will be returned.
           (type=Object)

getType()

Returns the type of the object.
Returns:

The type of object.

Example:

The example below works on the default scene. It retrieves all objects in the scene and updates the location and rotation of the camera. When run, the camera will rotate 180 degrees and moved to the oposite side of the X axis. Note that the number 'pi' in the example is an approximation of the true number 'pi':
   import Blender

   objects = Blender.Object.Get()

   for obj in objects:
       if obj.getType() == 'Camera':
           obj.LocY = -obj.LocY
           obj.RotZ = 3.141592 - obj.RotZ

   Blender.Redraw()

isSelected()

Returns the objects selection state as a boolean value True or False.
Returns:
Selection state as True or False
           (type=Boolean)

link(object)

Links Object with data provided in the argument. The data must match the Object's type, so you cannot link a Lamp to a Mesh type object.
Parameters:
object - A Blender Object.
           (type=Blender Object)

makeDisplayList()

Updates this object's display list. Blender uses display lists to store already transformed data (like a mesh with its vertices already modified by coordinate transformations and armature deformation). If the object isn't modified, there's no need to recalculate this data. This method is here for the *few cases* where a script may need it, like when toggling the "SubSurf" mode for a mesh:

Example:
object = Blender.Object.Get("Sphere")
nmesh = object.getData()
nmesh.setMode("SubSurf")
nmesh.update() # don't forget to update!
object.makeDisplayList()
Blender.Window.Redraw()
If you try this example without the line to update the display list, the object will disappear from the screen until you press "SubSurf".

Warning: If after running your script objects disappear from the screen or are not displayed correctly, try this method function. But if the script works properly without it, there's no reason to use it.

makeParent(objects, noninverse=0, fast=0)

Makes the object the parent of the objects provided in the argument which must be a list of valid Objects.
Parameters:
objects - A Blender Object.
           (type=Blender Object)
noninverse - 0 - make parent with inverse 1 - make parent without inverse
           (type=Integer)
fast - 0 - update scene hierarchy automatically 1 - don't update scene hierarchy (faster). In this case, you must explicitely update the Scene hierarchy.
           (type=Integer)

makeTrack(tracked, fast=0)

Make this Object track another.
Parameters:
tracked - the object to be tracked.
           (type=Blender Object)
fast - if zero, the scene hierarchy is updated automatically. If you set 'fast' to a nonzero value, don't forget to update the scene yourself (see Scene.Scene.update).
           (type=int (bool))

Note: you also need to clear the rotation (setEuler) of this object if it was not (0,0,0) already.

removeAllProperties()

Removes all properties from an object.

removeProperty(property)

Remove a property from an object.
Parameters:
property - property object to remove.
           (type=Property object)

select(boolean)

Sets the object's selection state.
Parameters:
boolean -
  • 0 - unselected
  • 1 - selected

           (type=Integer)

setDeltaLocation(delta_location)

Sets the object's delta location which must be a vector triple.
Parameters:
delta_location - A vector triple (x, y, z) specifying the new location.
           (type=A vector triple)

setDrawMode(drawmode)

Sets the object's drawing mode. The drawing mode can be a mix of modes. To enable these, add up the values.
Parameters:
drawmode - A sum of the following:
  • 2 - axis
  • 4 - texspace
  • 8 - drawname
  • 16 - drawimage
  • 32 - drawwire

           (type=Integer)

setDrawType(drawtype)

Sets the object's drawing type.
Parameters:
drawtype - One of the following:
  • 1 - Bounding box
  • 2 - Wire
  • 3 - Solid
  • 4 - Shaded
  • 5 - Textured

           (type=Integer)

setEuler(euler)

Sets the object's rotation according to the specified Euler angles.
Parameters:
euler - a python euler or x,y,z rotations as floats
           (type=Py_Euler or a list of floats)

setIpo(ipo)

Links an ipo to this object.
Parameters:
ipo - an object type ipo.
           (type=Blender Ipo)

setLocation(x, y, z)

Sets the object's location.
Parameters:
x - The X coordinate of the new location.
           (type=float)
y - The Y coordinate of the new location.
           (type=float)
z - The Z coordinate of the new location.
           (type=float)

setMaterials(materials)

Sets the materials. The argument must be a list of valid material objects.
Parameters:
materials - A list of Blender material objects.
           (type=Materials list)

setMatrix(matrix)

Sets the object's matrix and updates it's tranformation.
Parameters:
matrix - a python matrix 4x4.
           (type=Py_Matrix 4x4)

setName(name)

Sets the name of the object.
Parameters:
name - The new name for the object.
           (type=String)

setSize(x, y, z)

Sets the object's size.
Parameters:
x - The X size multiplier.
           (type=float)
y - The Y size multiplier.
           (type=float)
z - The Z size multiplier.
           (type=float)

setTimeOffset(timeOffset)

Sets the time offset of the object's animation.
Parameters:
timeOffset - The new time offset for the object's animation.
           (type=float)

shareFrom(object)

Link data of object specified in the argument with self. This works only if self and the object specified are of the same type.
Parameters:
object - A Blender Object of the same type.
           (type=Blender Object)

Class Variable Details

colbits

The Material usage mask. A set bit #n means: the Material #n in the Object's material list is used. Otherwise, the Material #n of the Objects Data material list is displayed.

data

The data of the object. (Read-only)

dloc

The delta (X,Y,Z) location coordinates of the object (vector). This variable applies to IPO Objects only.

dLocX

The delta X location coordinate of the object. This variable applies to IPO Objects only.

dLocY

The delta Y location coordinate of the object. This variable applies to IPO Objects only.

dLocZ

The delta Z location coordinate of the object. This variable applies to IPO Objects only.

drawMode

The object's drawing mode used. The value can be a sum of: 2 - axis, 4 - texspace, 8 - drawname, 16 - drawimage, 32 - drawwire.

drawType

The object's drawing type used. 1 - Bounding box, 2 - wire, 3 - Solid, 4- Shaded, 5 - Textured.

drot

The delta (X,Y,Z) rotation angles (in radians) of the object (vector). This variable applies to IPO Objects only.

dRotX

The delta X rotation angle (in radians) of the object. This variable applies to IPO Objects only.

dRotY

The delta Y rotation angle (in radians) of the object. This variable applies to IPO Objects only.

dRotZ

The delta Z rotation angle (in radians) of the object. This variable applies to IPO Objects only.

dsize

The delta (X,Y,Z) size of the object.

dSizeX

The delta X size of the object.

dSizeY

The delta Y size of the object.

dSizeZ

The delta Z size of the object.

EffX

The X effector coordinate of the object. Only applies to IKA.

EffY

The Y effector coordinate of the object. Only applies to IKA.

EffZ

The Z effector coordinate of the object. Only applies to IKA.

ipo

The ipo data associated with the object. (Read-only)

Layer

The object layer. This value is a bitmask with one position set for each of the 20 possible layers starting from the low order bit. The easiest way to deal with these values in in hexadecimal notation. Example:
 ob.Layer = 0x04 # sets layer 3 ( bit pattern 0100 )
After setting the Layer value, call Blender.Redraw( -1 ) to update the interface.

loc

The (X,Y,Z) location coordinates of the object (vector).

LocX

The X location coordinate of the object.

LocY

The Y location coordinate of the object.

LocZ

The Z location coordinate of the object.

mat

The matrix of the object relative to its parent. (Read-only)

matrix

The matrix of the object relative to its parent. (Read-only)

matrixLocal

The matrix of the object relative to its parent. (Read-only)

matrixWorld

The matrix of the object in world space. (Read-only)

name

The name of the object.

parent

The parent object of the object. (Read-only)

rot

The (X,Y,Z) rotation angles (in radians) of the object (vector).

RotX

The X rotation angle (in radians) of the object.

RotY

The Y rotation angle (in radians) of the object.

RotZ

The Z rotation angle (in radians) of the object.

sel

The selection state of the object, 1/0.

size

The (X,Y,Z) size of the object (vector).

SizeX

The X size of the object.

SizeY

The Y size of the object.

SizeZ

The Z size of the object.

track

The object tracking this object. (Read-only)

Generated by Epydoc 2.1 on Thu Aug 12 21:47:29 2004 http://epydoc.sf.net