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 as A
from Blender.Mathutils import *
#
arms = A.Get()
for arm in arms.values():
arm.drawType = A.STICK #set the draw type
arm.makeEditable() #enter editmode
#generating new editbone
eb = A.Editbone()
eb.roll = 10
eb.parent = arm.bones['Bone.003']
eb.head = Vector(1,1,1)
eb.tail = Vector(0,0,1)
eb.options = [A.HINGE, A.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 emptys 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.getActiveObject()
if not arm_ob or arm_ob.getType() != 'Armature':
Draw.PupMenu('not an armature object')
return
# Deselect all
for ob in scn.getChildren():
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= Object.New('Empty', bone.name)
scn.link(ob_empty)
ob_empty.setMatrix(bone_mat_world)
ob_empty.sel= 1
# Select then de-select keeps us active
arm_ob.sel= 1
arm_ob.sel= 0
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. |
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 |
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)
|
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
|