Module Armature
source code
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()
|
Armature
This object gives access to Armature-specific data in
Blender.
|
|
BonesDict
This object gives gives dictionary like access to the bones in
an armature.
|
|
Bone
This object gives access to Bone-specific data in Blender.
|
|
Editbone
This object is a wrapper for editbone data and is used only in
the manipulation of the armature in editmode.
|
Blender Armature or a list of Blender Armatures
|
|
Blender Armature.
|
|
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
|
LOCKED_EDIT
Prevents the bone from being transformed in editmode
|
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 the Armature object(s) from Blender.
- Parameters:
name (string, nothing, or list of strings) - The string name of an armature.
- Returns: Blender Armature or a list of Blender Armatures
- 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.
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.
|
Return a new armature.
- Parameters:
name (string or nothing) - The string name of the new armature.
- Returns: Blender Armature.
- A new armature.
|