Module Armature
[frames | no frames]

Module Armature

The Blender.Armature submodule.

Armature

This module provides access to Armature objects in Blender. These are "skeletons", used to deform and animate other objects -- meshes, for example.

Example:
 import Blender
 from Blender import Armature
 from Blender.Mathutils import *
 #
 arms = Armature.Get()
 for arm in arms.values():
   arm.drawType = Armature.STICK #set the draw type
   arm.makeEditable() #enter editmode

   #generating new editbone
   eb = Armature.Editbone()
   eb.roll = 10
   eb.parent = arm.bones['Bone.003']
   eb.head = Vector(1,1,1)
   eb.tail = Vector(0,0,1)
   eb.options = [Armature.HINGE, Armature.CONNECTED]

   #add the bone
   arm.bones['myNewBone'] = eb
 
   #delete an old bone
   del arm.bones['Bone.002']

   arm.update()  #save changes

   for bone in arm.bones.values():
     #print bone.matrix['ARMATURESPACE']
     print bone.parent, bone.name
     print bone.children, bone.name
     print bone.options, bone.name
Example:
       # Adds empties for every bone in the selected armature, an example of getting worldspace locations for bones.
       from Blender import *
       def test_arm():
               scn= Scene.GetCurrent()
               arm_ob= scn.objects.active

               if not arm_ob or arm_ob.type != 'Armature':
                       Draw.PupMenu('not an armature object')
                       return

               # Deselect all
               for ob in scn.objects:
                       if ob != arm_ob:
                               ob.sel= 0

               arm_mat= arm_ob.matrixWorld

               arm_data= arm_ob.getData()

               bones= arm_data.bones.values()
               for bone in bones:
                       bone_mat= bone.matrix['ARMATURESPACE']
                       bone_mat_world= bone_mat*arm_mat

                       ob_empty= scn.objects.new('Empty')
                       ob_empty.setMatrix(bone_mat_world)

       test_arm()

Classes
Armature This object gives access to Armature-specific data in Blender.
Bone This object gives access to Bone-specific data in Blender.
BonesDict This object gives gives dictionary like access to the bones in an armature.
Editbone This object is a wrapper for editbone data and is used only in the manipulation of the armature in editmode.

Function Summary
Blender Armature or a list of Blender Armatures Get(name)
Get the Armature object(s) from Blender.
Blender Armature. New(name)
Return a new armature.

Variable Summary
Constant BBONE: Bones draw as a segmented B-spline
Constant BONE_SELECTED: Bone is selected
Constant CONNECTED: Connect this bone to parent
Constant ENVELOPE: Bones draw as a stick with envelope influence
Constant HIDDEN_EDIT: Bone is hidden in editmode
Constant HINGE: Don't inherit rotation or scale from parent
Constant MULTIPLY: Multiply bone with vertex group
Constant NO_DEFORM: If bone will not deform geometry
Constant OCTAHEDRON: Bones drawn as octahedrons
Constant ROOT_SELECTED: Root of the Bone is selected
Constant STICK: Bones drawn as a line
Constant TIP_SELECTED: Tip of the Bone is selected

Function Details

Get(name=None)

Get the Armature object(s) from Blender.
Parameters:
name - The string name of an armature.
           (type=string, nothing, or list of strings)
Returns:
It depends on the name parameter:
  • (name): The Armature object with the given name;
  • (name, name, ...): A list of Armature objects
  • (): A list with all Armature objects in the current scene.

           (type=Blender Armature or a list of Blender Armatures)

Warning: In versions 2.42 and earlier, a string argument for an armature that doesn't exist will return None. Later versions raise a Value error.

New(name=None)

Return a new armature.
Parameters:
name - The string name of the new armature.
           (type=string or nothing)
Returns:
A new armature.
           (type=Blender Armature.)

Variable Details

BBONE

Bones draw as a segmented B-spline
Type:
Constant

BONE_SELECTED

Bone is selected
Type:
Constant

CONNECTED

Connect this bone to parent
Type:
Constant

ENVELOPE

Bones draw as a stick with envelope influence
Type:
Constant

HIDDEN_EDIT

Bone is hidden in editmode
Type:
Constant

HINGE

Don't inherit rotation or scale from parent
Type:
Constant

MULTIPLY

Multiply bone with vertex group
Type:
Constant

NO_DEFORM

If bone will not deform geometry
Type:
Constant

OCTAHEDRON

Bones drawn as octahedrons
Type:
Constant

ROOT_SELECTED

Root of the Bone is selected
Type:
Constant

STICK

Bones drawn as a line
Type:
Constant

TIP_SELECTED

Tip of the Bone is selected
Type:
Constant

Generated by Epydoc 2.1 on Thu May 10 20:31:59 2007 http://epydoc.sf.net