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

Class Object


The Object object

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

Note: When dealing with properties and functions such as LocX/RotY/getLocation(), getSize() and getEuler() Keep in mind that these transformation properties are relative to the objects parent (if any).

To get these values in worldspace (taking into acount vertex parents, constraints etc) pass the argument 'worldspace' to these functions.
Method Summary
  addProperty(name_or_property, data, type)
Add or create a property for an object.
  addScriptLink(text, event)
Add a new script link to this Object.
  buildParts()
Recomputes the particle system.
  clearIpo()
Unlinks the ipo from this object.
  clearScriptLinks(links)
Delete script links from this Object.
  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.
  evaluatePose(framenumber)
Evaluates the Pose based on its currently bound action at a certain frame.
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 (WRAPPED DATA) getBoundBox()
Returns the worldspace bounding box of this object.
specific Object type or string getData(name_only, mesh)
Returns the Datablock object (Mesh, Lamp, Camera, etc.) linked to this Object.
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(space)
Return a python Euler.
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(space)
Return (x, y, z)
list of Material Objects getMaterials(what)
Returns a list of materials assigned to the object.
Py_Matrix (WRAPPED DATA) getMatrix(space)
Returns the object matrix.
  getName()
Returns the name of the object
Object getParent()
Returns the object's parent object.
String getParentBoneName()
Returns the object's parent object's sub name, or None.
int getPIDeflection()
Get the Object's Particle Interaction Deflection Setting.
float getPIFalloff()
Get the Object's Particle Interaction falloff.
float getPIMaxDist()
Get the Object's Particle Interaction MaxDist.
float getPIPermf()
Get the Object's Particle Interaction Permeability.
float getPIRandomDamp()
Get the Object's Particle Interaction RandomDamp.
float getPIStregth()
Get the Object's Particle Interaction Strength.
float getPISurfaceDamp()
Get the Object's Particle Interaction SurfaceDamp.
int getPIType()
Get the Object's Particle Interaction Type.
int getPIUseMaxDist()
Get the Object's Particle Interaction if using MaxDist.
Pose object getPose()
Gets the current Pose of the object.
Property object getProperty(name)
Return a properties from this object based on name.
float getSBDefaultGoal()
Get the Object's SB DefaultGoal.
float getSBErrorLimit()
Get the Object's SB ErrorLimit.
float getSBFriction()
Get the Object's SB Friction.
float getSBGoalFriction()
Get the Object's SB GoalFriction.
float getSBGoalSpring()
Get the Object's SB GoalSpring.
float getSBGravity()
Get the Object's SB Gravity.
float getSBInnerSpring()
Get the Object's SB InnerSpring.
float getSBInnerSpringFriction()
Get the Object's SB InnerSpringFriction.
float getSBMass()
Get the Object's SB Mass.
float getSBMaxGoal()
Get the Object's SB MaxGoal.
float getSBMinGoal()
Get the Object's SB MinGoal.
int getSBPostDef()
get SoftBodies PostDef option
int getSBStiffQuads()
get SoftBodies StiffQuads option
int getSBUseEdges()
get SoftBodies UseEdges option
int getSBUseGoal()
get SoftBodies UseGoal option
list getScriptLinks(event)
Get a list with this Object's script links of type 'event'.
  getSize(space)
Return (SizeX, SizeY, SizeZ)
  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 in 'Armature', 'Camera', 'Curve', 'Lamp', 'Lattice', 'MBall', 'Mesh', 'Surf', 'Empty', 'Wave' (deprecated) or 'unknown' in exceptional cases.
  insertIpoKey(keytype)
Inserts keytype values in object ipo at curframe.
  insertShapeKey()
Insert a Shape Key in the current object.
int isSB()
Get if the Object's SB is Enabled.
Boolean isSelected()
Returns the objects selection state in the current scene as a boolean value True or False.
  join(objects)
Uses the object as a base for all of the objects in the provided list to join into.
  link(datablock)
Links Object with ObData datablock 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.
  makeParentDeform(objects, noninverse, fast)
Makes the object the deformation parent of the objects provided in the argument which must be a list of valid Objects.
  makeParentVertex(objects, indices, noninverse, fast)
Makes the object the vertex 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 in the current scene.
  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 localspace rotation according to the specified Euler angles.
  setIpo(ipo)
Links an ipo to this object.
  setLocation(x, y, z)
Sets the object's location relative to the parent object (if any).
  setMaterials(materials)
Sets the materials.
  setMatrix(matrix)
Sets the object's matrix and updates its transformation.
  setName(name)
Sets the name of the object.
PyNone setPIDeflection(status)
Set the the Object's Particle Interaction Deflection Setting.
PyNone setPIFalloff(falloff)
Set the the Object's Particle Interaction falloff.
PyNone setPIMaxDist(MaxDist)
Set the the Object's Particle Interaction MaxDist.
PyNone setPIPerm(perm)
Set the the Object's Particle Interaction Permeability.
PyNone setPIRandomDamp(damp)
Set the the Object's Particle Interaction RandomDamp.
PyNone setPIStrength(strength)
Set the the Object's Particle Interaction Strength.
PyNone setPISurfaceDamp(damp)
Set the the Object's Particle Interaction SurfaceDamp.
PyNone setPIType(type)
Set the the Object's Particle Interaction type.
PyNone setPIUseMaxDist(status)
Set the the Object's Particle Interaction MaxDist.
PyNone setSBDefaultGoal(goal)
Set the the Object's SB DefaultGoal.
PyNone setSBErrorLimit(err)
Set the the Object's SB ErrorLimit.
PyNone setSBFriction(frict)
Set the the Object's SB Friction.
PyNone setSBGoalFriction(gf)
Set the the Object's SB GoalFriction.
PyNone setSBGoalSpring(gs)
Set the the Object's SB GoalSpring.
PyNone setSBGravity(grav)
Set the the Object's SB Gravity.
PyNone setSBInnerSpring(sprr)
Set the the Object's SB InnerSpring.
PyNone setSBInnerSpringFriction(sprf)
Set the the Object's SB InnerSpringFriction.
PyNone setSBMass(mass)
Set the the Object's SB Mass.
PyNone setSBMaxGoal(mg)
Set the the Object's SB MaxGoal.
PyNone setSBMinGoal(mg)
Set the the Object's SB MinGoal.
PyNone setSBPostDef(switch)
Enable / Disable SoftBodies PostDef option 1: on 0: off
PyNone setSBStiffQuads(switch)
Enable / Disable SoftBodies StiffQuads option 1: on 0: off
PyNone setSBUseEdges(switch)
Enable / Disable SoftBodies UseEdges option 1: on 0: off
PyNone setSBUseGoal(switch)
Enable / Disable SoftBodies UseGoal option 1: on 0: off
  setSize(x, y, z)
Sets the object's size, relative to the parent object (if any), clamped
  setTimeOffset(timeOffset)
Sets the time offset of the object's animation.
  shareFrom(object)
Link data of object specified in the argument with self.

Instance Variable Summary
BPy_ActionStrips actionStrips: a sequence of action strips for the object.
  colbits: The Material usage mask.
BPy_Constraints constraints: a sequence of constraints for the object.
  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.
float drawSize: The drawsize for empty objects.
  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.
int DupEnd: The DupliFrame end frame.
Group or None DupGroup: The DupliGroup Animation Property.
list of tuples containing (object, matrix) DupObjects: The Dupli object instances.
int DupOff: The DupliFrame removal of every Nth frame for this object.
int DupOn: The DupliFrames in sucsession between DupOff frames.
int DupSta: The DupliFrame starting frame.
  effects: The list of particle effects associated with the object.
bool (True/False) enableDupFrames: The DupliFrames status of the object.
bool (True/False) Set True to make this object an instance of the objects DupGroup. enableDupGroup: The DupliGroup status of the object.
bool (True/False) enableDupNoSpeed: The DupliNoSpeed status of the object.
bool (True/False) enableDupRot: The DupliRot status of the object.
bool (True/False) enableDupVerts: The DupliVerts status of the object.
  ipo: The ipo data associated with the object.
integer (bitmask) Layers: The object layers (also check the newer attribute layers).
list of integers layers: The layers this object is visible in (also check the older attribute Layers).
  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: alias for matrix: the matrix of the object in world space.
  matrix: The matrix of the object in world space, same as matrixWorld.
  matrixLocal: The matrix of the object relative to its parent (or matrixWorld if there is no parent).
  matrixWorld: The matrix of the object in world space.
BPy_Modifiers modifiers: a sequence of modifiers for the object.
  name: The name of the object, 21 chars max.
  parent: The parent object of the object.
  parentbonename: The string name of the parent bone.
int protectFlags: The "transform locking" bitfield flags for the object.
int rbFlags: Rigid body flags.
float rbMass: Rigid body mass.
int rbShapeBoundType: Rigid body shape bound type.
  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 in the current scene, 1 is selected, 0 is unselected.
  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.
int users: The number of users of the object.

Method Details

addProperty(name_or_property, data, type)

Add or create a property for an object. If called with only a property object, the property is assigned to the object. If called with a property name string and data object, a new property is created and added to the object.
Parameters:
name_or_property - the property name, or a property object.
           (type=string or Property object)
data - Only valid when name_or_property is a string. Value depends on what is passed in:
  • string: string type property
  • int: integer type property
  • float: float type property

           (type=string, int or float)
type - Only valid when name_or_property is a string. Can be the following:
  • 'BOOL'
  • 'INT'
  • 'FLOAT'
  • 'TIME'
  • 'STRING'

           (type=string (optional))

Warnings:

  • If a type is not declared string data will become string type, int data will become int type and float data will become float type. Override type to declare bool type, and time type.
  • 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", "Redraw" or "Render".
           (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(links=None)

Delete script links from this Object. If no list is specified, all script links are deleted.
Parameters:
links - None (default) or a list of Blender Text names.
           (type=list of strings)

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 receive the properties.
           (type=Object object)

evaluatePose(framenumber)

Evaluates the Pose based on its currently bound action at a certain frame.
Parameters:
framenumber - The frame number to evaluate to.
           (type=Int)

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 worldspace 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. Data is wrapped when bounding box is present.
           (type=list of 8 (x,y,z) float coordinate vectors (WRAPPED DATA))

getData(name_only=False, mesh=False)

Returns the Datablock object (Mesh, Lamp, Camera, etc.) linked to this Object. If the keyword parameter 'name_only' is True, only the Datablock name is returned as a string. It the object is of type Mesh, then the 'mesh' keyword can also be used; if True the data return is a Mesh object, otherwise it is an NMesh object (the default). Using the mesh keyword is ignored for non mesh objects.
Parameters:
name_only - This is a keyword parameter. If True (or nonzero), only the name of the data object is returned.
           (type=bool)
mesh - This is a keyword parameter. If True (or nonzero), a Mesh data object is returned.
           (type=bool)
Returns:
Depends on the type of Datablock linked to the Object. If name_only is True, it returns a string.
           (type=specific Object type or string)

Notes:

  • For Mesh objects Mesh is faster then NMesh because Mesh is a thin wrapper.
  • This function is different from NMesh.GetRaw and Mesh.Get because it keeps a link to the original mesh which it needed if your dealing with Mesh weight groups.

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
  • 64 - xray

           (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(space)

Parameters:
space - The desired space for the size:
  • localspace: (default) relative to the object's parent;
  • worldspace: absolute, taking vertex parents, tracking and Ipo's into account;
Returns the object's localspace rotation as Euler rotation vector (rotX, rotY, rotZ). Angles are in radians.
           (type=string)
Returns:
A python Euler. Data is wrapped when euler is present.
           (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(space)

Parameters:
space - The desired space for the location:
  • localspace: (default) relative to the object's parent;
  • worldspace: absolute, taking vertex parents, tracking and Ipo's into account;
Returns the object's location (x, y, z).
           (type=string)
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()

Note: the worldspace location is the same as ob.matrixWorld[3][0:3]

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='worldspace')

Returns the object matrix.
Parameters:
space - The desired matrix:
  • worldspace (default): absolute, taking vertex parents, tracking and Ipo's into account;
  • localspace: relative to the object's parent (returns worldspace matrix if the object doesn't have a parent);
  • old_worldspace: old behavior, prior to Blender 2.34, where eventual changes made by the script itself were not taken into account until a redraw happened, either called by the script or upon its exit.
Returns the object matrix.
           (type=string)
Returns:
a python 4x4 matrix object. Data is wrapped for 'worldspace'
           (type=Py_Matrix (WRAPPED DATA))

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)

getParentBoneName()

Returns the object's parent object's sub name, or None. For objects parented to bones, this is the name of the bone.
Returns:
The parent object sub-name of the object. If not available, None will be returned.
           (type=String)

getPIDeflection()

Get the Object's Particle Interaction Deflection Setting.
Returns:
int

getPIFalloff()

Get the Object's Particle Interaction falloff.
Returns:
float

getPIMaxDist()

Get the Object's Particle Interaction MaxDist.
Returns:
float

getPIPermf()

Get the Object's Particle Interaction Permeability.
Returns:
float

getPIRandomDamp()

Get the Object's Particle Interaction RandomDamp.
Returns:
float

getPIStregth()

Get the Object's Particle Interaction Strength.
Returns:
float

getPISurfaceDamp()

Get the Object's Particle Interaction SurfaceDamp.
Returns:
float

getPIType()

Get the Object's Particle Interaction Type.
Returns:
int

getPIUseMaxDist()

Get the Object's Particle Interaction if using MaxDist.
Returns:
int

getPose()

Gets the current Pose of the object.
Returns:
the current pose object
           (type=Pose 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)

getSBDefaultGoal()

Get the Object's SB DefaultGoal.
Returns:
float

getSBErrorLimit()

Get the Object's SB ErrorLimit.
Returns:
float

getSBFriction()

Get the Object's SB Friction.
Returns:
float

getSBGoalFriction()

Get the Object's SB GoalFriction.
Returns:
float

getSBGoalSpring()

Get the Object's SB GoalSpring.
Returns:
float

getSBGravity()

Get the Object's SB Gravity.
Returns:
float

getSBInnerSpring()

Get the Object's SB InnerSpring.
Returns:
float

getSBInnerSpringFriction()

Get the Object's SB InnerSpringFriction.
Returns:
float

getSBMass()

Get the Object's SB Mass.
Returns:
float

getSBMaxGoal()

Get the Object's SB MaxGoal.
Returns:
float

getSBMinGoal()

Get the Object's SB MinGoal.
Returns:
float

getSBPostDef()

get SoftBodies PostDef option
Returns:
int

getSBStiffQuads()

get SoftBodies StiffQuads option
Returns:
int

getSBUseEdges()

get SoftBodies UseEdges option
Returns:
int

getSBUseGoal()

get SoftBodies UseGoal option
Returns:
int

getScriptLinks(event)

Get a list with this Object's script links of type 'event'.
Parameters:
event - "FrameChanged", "Redraw" or "Render".
           (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(space)

Parameters:
space - The desired space for the size:
  • localspace: (default) relative to the object's parent;
  • worldspace: absolute, taking vertex parents, tracking and Ipo's into account;
Returns the object's size.
           (type=string)
Returns:
(SizeX, SizeY, SizeZ)

Note: the worldspace size will not return negative (flipped) scale values.

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 in 'Armature', 'Camera', 'Curve', 'Lamp', 'Lattice', 'MBall', 'Mesh', 'Surf', 'Empty', 'Wave' (deprecated) or 'unknown' in exceptional cases.
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 opposite side of the X axis. Note that the number 'pi' in the example is an approximation of the true number 'pi'. A better, less error-prone value of pi is math.pi from the python math module.:
   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()

insertIpoKey(keytype)

Inserts keytype values in object ipo at curframe. Uses module constants.
Parameters:
keytype - -LOC -ROT -SIZE -LOCROT -LOCROTSIZE -PI_STRENGTH -PI_FALLOFF -PI_PERM -PI_SURFACEDAMP -PI_RANDOMDAMP
           (type=Integer)
Returns:
py_none

insertShapeKey()

Insert a Shape Key in the current object. It applies to Objects of the type Mesh, Lattice, or Curve.

isSB()

Get if the Object's SB is Enabled.
Returns:
int

isSelected()

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

join(objects)

Uses the object as a base for all of the objects in the provided list to join into.
Parameters:
objects - A list of objects matching the objects type.
           (type=Sequence of Blender Object)

Notes:

  • Objects in the list will not be removed from the scene, to avoid overlapping data you may want to remove them manualy after joining.
  • Join modifies the base objects data in place so that other objects are joined into it. no new object or data is created.
  • Join will only work for object types Mesh, Armature, Curve and Surface, an error will be raised if the object is not of this type.
  • objects in the list will be ignored if they to not match the base object.
  • objects must be in the current scene to be joined.
  • this function will not work in background mode (no user interface)
  • An error in the join function input will raise a TypeError, otherwise an error in the data input will raise a RuntimeError, for situations where you don't have tight control on the data that is being joined, you should handel the RuntimeError error, litting the user know the data cant be joined. This an happen if the data is too large or one of the objects data has a shape key.

link(datablock)

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

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:
import Blender
scene= Blender.Scene.GetCurrent()
object= scene.getActiveObject()
object.modifiers.append(Blender.Modifier.Type.SUBSURF)
object.makeDisplayList()
Blender.Window.RedrawAll()
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 - The children of the parent
           (type=Sequence of 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)

Warning: objects must first be linked to a scene before they can become parents of other objects. Calling this makeParent method for an unlinked object will result in an error.

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

Makes the object the deformation parent of the objects provided in the argument which must be a list of valid Objects. The parent object must be a Curve or Armature.
Parameters:
objects - The children of the parent
           (type=Sequence of 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)

Warnings:

  • objects must first be linked to a scene before they can become parents of other objects. Calling this makeParent method for an unlinked object will result in an error.
  • child objects must be of mesh type to deform correctly. Other object types will fall back to normal parenting silently.

makeParentVertex(objects, indices, noninverse=0, fast=0)

Makes the object the vertex parent of the objects provided in the argument which must be a list of valid Objects. The parent object must be a Mesh, Curve or Surface.
Parameters:
objects - The children of the parent
           (type=Sequence of Blender Object)
indices - The indices of the vertices you want to parent to (1 or 3 values)
           (type=Tuple of Integers)
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)

Warning: objects must first be linked to a scene before they can become parents of other objects. Calling this makeParent method for an unlinked object will result in an error.

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 or property name to be removed.
           (type=Property object or string)

select(boolean)

Sets the object's selection state in the current scene. setting the selection will make this object the active object of this scene.
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
  • 64 - xray

           (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 localspace 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 relative to the parent object (if any).
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 16 items or less. Each list element is either a Material or None. Also see colbits.
Parameters:
materials - A list of Blender material objects.
           (type=Materials list)

Note: Blender materials are assigned to the objects data by default. So unless you know the material is applied to the object or are changing the objects colbits then you need to look at the object datas materials.

setMatrix(matrix)

Sets the object's matrix and updates its transformation.
Parameters:
matrix - a 3x3 or 4x4 Python matrix. If a 3x3 matrix is given, it is extended to a 4x4 matrix.
           (type=Py_Matrix 3x3 or 4x4)

setName(name)

Sets the name of the object. A string longer then 20 characters will be shortened.
Parameters:
name - The new name for the object.
           (type=String)

setPIDeflection(status)

Set the the Object's Particle Interaction Deflection Setting. 0 = Off, 1 = on
Parameters:
status - the new status
           (type=int)
Returns:
PyNone

setPIFalloff(falloff)

Set the the Object's Particle Interaction falloff. Values between 0 to 10.0
Parameters:
falloff - the Object's Particle Interaction New falloff.
           (type=float)
Returns:
PyNone

setPIMaxDist(MaxDist)

Set the the Object's Particle Interaction MaxDist. Values between 0 to 1000.0
Parameters:
MaxDist - the Object's Particle Interaction New MaxDist.
           (type=float)
Returns:
PyNone

setPIPerm(perm)

Set the the Object's Particle Interaction Permeability. Values between 0 to 10.0
Parameters:
perm - the Object's Particle Interaction New Permeability.
           (type=float)
Returns:
PyNone

setPIRandomDamp(damp)

Set the the Object's Particle Interaction RandomDamp. Values between 0 to 10.0
Parameters:
damp - the Object's Particle Interaction New RandomDamp.
           (type=float)
Returns:
PyNone

setPIStrength(strength)

Set the the Object's Particle Interaction Strength. Values between -1000.0 to 1000.0
Parameters:
strength - the Object's Particle Interaction New Strength.
           (type=float)
Returns:
PyNone

setPISurfaceDamp(damp)

Set the the Object's Particle Interaction SurfaceDamp. Values between 0 to 10.0
Parameters:
damp - the Object's Particle Interaction New SurfaceDamp.
           (type=float)
Returns:
PyNone

setPIType(type)

Set the the Object's Particle Interaction type. Use Module Constants
  • NONE
  • WIND
  • FORCE
  • VORTEX
  • MAGNET
Parameters:
type - the Object's Particle Interaction Type.
           (type=int)
Returns:
PyNone

setPIUseMaxDist(status)

Set the the Object's Particle Interaction MaxDist. 0 = Off, 1 = on
Parameters:
status - the new status
           (type=int)
Returns:
PyNone

setSBDefaultGoal(goal)

Set the the Object's SB DefaultGoal. Values between 0 to 1.0
Parameters:
goal - the Object's SB New DefaultGoal.
           (type=float)
Returns:
PyNone

setSBErrorLimit(err)

Set the the Object's SB ErrorLimit. Values between 0 to 1.0
Parameters:
err - the Object's SB New ErrorLimit.
           (type=float)
Returns:
PyNone

setSBFriction(frict)

Set the the Object's SB Friction. Values between 0 to 10.0
Parameters:
frict - the Object's SB New Friction.
           (type=float)
Returns:
PyNone

setSBGoalFriction(gf)

Set the the Object's SB GoalFriction. Values between 0 to 10.0
Parameters:
gf - the Object's SB New GoalFriction.
           (type=float)
Returns:
PyNone

setSBGoalSpring(gs)

Set the the Object's SB GoalSpring. Values between 0 to 0.999
Parameters:
gs - the Object's SB New GoalSpring.
           (type=float)
Returns:
PyNone

setSBGravity(grav)

Set the the Object's SB Gravity. Values between 0 to 10.0
Parameters:
grav - the Object's SB New Gravity.
           (type=float)
Returns:
PyNone

setSBInnerSpring(sprr)

Set the the Object's SB InnerSpring. Values between 0 to 0.999
Parameters:
sprr - the Object's SB New InnerSpring.
           (type=float)
Returns:
PyNone

setSBInnerSpringFriction(sprf)

Set the the Object's SB InnerSpringFriction. Values between 0 to 10.0
Parameters:
sprf - the Object's SB New InnerSpringFriction.
           (type=float)
Returns:
PyNone

setSBMass(mass)

Set the the Object's SB Mass. Values between 0 to 50.0
Parameters:
mass - the Object's SB New mass.
           (type=float)
Returns:
PyNone

setSBMaxGoal(mg)

Set the the Object's SB MaxGoal. Values between 0 to 1.0
Parameters:
mg - the Object's SB New MaxGoal.
           (type=float)
Returns:
PyNone

setSBMinGoal(mg)

Set the the Object's SB MinGoal. Values between 0 to 1.0
Parameters:
mg - the Object's SB New MinGoal.
           (type=float)
Returns:
PyNone

setSBPostDef(switch)

Enable / Disable SoftBodies PostDef option 1: on 0: off
Parameters:
switch - the Object's SB New PostDef Value.
           (type=int)
Returns:
PyNone

setSBStiffQuads(switch)

Enable / Disable SoftBodies StiffQuads option 1: on 0: off
Parameters:
switch - the Object's SB New StiffQuads Value.
           (type=int)
Returns:
PyNone

setSBUseEdges(switch)

Enable / Disable SoftBodies UseEdges option 1: on 0: off
Parameters:
switch - the Object's SB New UseEdges Value.
           (type=int)
Returns:
PyNone

setSBUseGoal(switch)

Enable / Disable SoftBodies UseGoal option 1: on 0: off
Parameters:
switch - the Object's SB New UseGoal Value.
           (type=int)
Returns:
PyNone

setSize(x, y, z)

Sets the object's size, relative to the parent object (if any), clamped
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)

Note: This funtion is faster then using getData() and setData() because it skips making a python object from the objects data.


Instance Variable Details

actionStrips

a sequence of action strips for the object.
Type:
BPy_ActionStrips

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. Example:
   object.colbits = (1<<0) + (1<<5) # use mesh materials 0 (1<<0) and 5 (1<<5)
                         # use object materials for all others

constraints

a sequence of constraints for the object.
Type:
BPy_Constraints

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, 64 - xray.

drawSize

The drawsize for empty objects. 1.0. is default.
Type:
float

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.

DupEnd

The DupliFrame end frame. (Use with enableDupFrames)
Type:
int

DupGroup

The DupliGroup Animation Property. Assign a group to DupGroup to make this object an instance of that group. This does not enable or disable the dupliGroup option, for that use getDupliGroup and setDupliGroup. The dupliGroup is None when this object does not have a dupliGroup. (Use with enableDupGroup)
Type:
Group or None

DupObjects

The Dupli object instances. Read-only. Returns of list of tuples for object duplicated by dupliframe, dupliverts dupligroups and other animation properties. The first tuple item is the original object that is duplicated, the second is the 4x4 worldspace dupli-matrix. Example:
import Blender
from Blender import Object, Scene, Mathutils

ob= Object.Get('Cube')
dupe_obs= ob.DupObjects
scn= Scene.GetCurrent()
for dupe_ob, dupe_matrix in dupe_obs:
  print dupe_ob.name
  empty_ob= Object.New('Empty')
  scn.link(empty_ob)
  empty_ob.setMatrix(dupe_matrix)
Blender.Redraw()
Type:
list of tuples containing (object, matrix)

DupOff

The DupliFrame removal of every Nth frame for this object. (Use with enableDupFrames)
Type:
int

DupOn

The DupliFrames in sucsession between DupOff frames. (Use with enableDupFrames and DupOff > 0)
Type:
int

DupSta

The DupliFrame starting frame. (Use with enableDupFrames)
Type:
int

effects

The list of particle effects associated with the object. (Read-only)

enableDupFrames

The DupliFrames status of the object. True/False - does not indicate that this object has any dupliFrames, (as returned by DupObjects) just that dupliFrames are enabled.
Type:
bool (True/False)

enableDupGroup

The DupliGroup status of the object. True/False - Set DupGroup to a group for this to take effect, Use DupObjects to get the object data from this instance. (Use with DupObjects)
Type:
bool (True/False) Set True to make this object an instance of the objects DupGroup.

enableDupNoSpeed

The DupliNoSpeed status of the object. True/False - Use with enableDupFrames to ignore dupliFrame speed. (Use with enableDupFrames)
Type:
bool (True/False)

enableDupRot

The DupliRot status of the object. True/False - Use with enableDupVerts to rotate each instance by the vertex normal. (Use with enableDupVerts)
Type:
bool (True/False)

enableDupVerts

The DupliVerts status of the object. True/False - does not indicate that this object has any dupliVerts, (as returned by DupObjects) just that dupliVerts are enabled.
Type:
bool (True/False)

ipo

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

Layers

The object layers (also check the newer attribute layers). This value is a bitmask with at least one position set for 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.
Type:
integer (bitmask)

layers

The layers this object is visible in (also check the older attribute Layers). This returns a list of integers in the range [1, 20], each number representing the respective layer. Setting is done by passing a list of ints or an empty list for no layers. Example:
 ob.layers = []  # object won't be visible
 ob.layers = [1, 4] # object visible only in layers 1 and 4
 ls = o.layers
 ls.append([10])
 o.layers = ls
 print ob.layers # will print: [1, 4, 10]
Note: changes will only be visible after the screen (at least the 3d View and Buttons windows) is redrawn.
Type:
list of integers

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

alias for matrix: the matrix of the object in world space. (Read-only)

matrix

The matrix of the object in world space, same as matrixWorld. (Read-only)

matrixLocal

The matrix of the object relative to its parent (or matrixWorld if there is no parent). (Read-only)

matrixWorld

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

modifiers

a sequence of modifiers for the object.
Type:
BPy_Modifiers

name

The name of the object, 21 chars max.

parent

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

parentbonename

The string name of the parent bone.

protectFlags

The "transform locking" bitfield flags for the object. Setting bits lock the following attributes:
  • bit 0: X location
  • bit 1: Y location
  • bit 2: Z location
  • bit 3: X rotation
  • bit 4: Y rotation
  • bit 5: Z rotation
  • bit 6: X size
  • bit 7: Y size
  • bit 8: Z size
Type:
int

rbFlags

Rigid body flags.
Type:
int

rbMass

Rigid body mass. Must be a positive value.
Type:
float

rbShapeBoundType

Rigid body shape bound type.
Type:
int

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 in the current scene, 1 is selected, 0 is unselected. (Selecting makes the object active)

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)

users

The number of users of the object. (Read-only)
Type:
int

Generated by Epydoc 2.1 on Thu Jul 13 16:50:05 2006 http://epydoc.sf.net