blendersynth.blender.armature

Armature object for managing pose

class blendersynth.blender.armature.Armature(object)[source]

This class manages armatures - a collection of posable bones.

add_constraint(bone, constraint_name, target=None, **kwargs)[source]

Applies a generic bone constraint. Returns BoneConstraint object

Parameters:
  • bone (Union[str, PoseBone]) – Bone to apply constraint to

  • constraint_name (str)

  • target (Empty) – Empty target. If none given, will create one.

Return type:

BoneConstraint

Any other constraint specific keyword arguments given as well will be fed into the new constraint

animate_path(frames=(0, 250), fracs=(0, 1))

Animate object along path.

Parameters:
  • frames (tuple) – tuple of keyframes to animate at - length N

  • fracs (tuple) – tuple of fractions along path to animate at - length N

property axes: ndarray

Return 3x3 rotation matrix (normalized) to represent axes

clear_pose(rot=True, location=True, scale=True, bones=None)[source]

Clear the pose of the armature. For the target bones, sets poses to zero, and removes any IK constraints.

Parameters:
  • rot – Clear rotation

  • location – Clear location

  • scale – Clear scale

  • bones – List of bones to clear. If not given, will clear all bones.

follow_path(path, zero=True, animate=True, frames=(0, 250), fracs=(0, 1))

Follow path, with optional animation setting.

Parameters:
  • path (Curve) – Curve object

  • zero (bool) – If True, set camera location to (0, 0, 0) [aligns camera with path]

  • animate (bool) – If True, animate camera along path

  • frames (tuple) – tuple of keyframes to animate at - length N

  • fracs (tuple) – tuple of fractions along path to animate at - length N

get_bone(bone)[source]

Get bone from armature.

Parameters:

bone_name – Name of bone to get (or PoseBone object)

Return type:

PoseBone

Returns:

PoseBone object

property location: mathutils.Vector

Location of object

property matrix_world

Return world matrix of object(s).

path_keyframe(frame, offset)

Set keyframe for camera path offset

Parameters:
  • frame (int) – Frame number

  • offset (float) – Offset fraction (0-1)

pose_bone(bone, rotation=None, location=None, scale=None, frame=None)[source]

Set the pose of a bone by giving a Euler XYZ rotation and/or location.

Parameters:
  • bone (Union[str, PoseBone]) – Name of bone to pose, or PoseBone object

  • rotation (Union[Vector, ndarray, List, Tuple]) – Euler XYZ rotation in radians

  • location (Union[Vector, ndarray, List, Tuple]) – Location of bone

  • scale (Union[Vector, ndarray, List, Tuple]) – Scale of bone

  • frame (int) – Frame to set pose on. If given, will insert keyframe here.

remove()

Delete .obj from bpy.data if it exists

render_visibility(value, frame=None)

Show/hide object in render

Parameters:
  • value (bool) – True to show, False to hide

  • frame (int) – Optional frame for animating

rotate_by(rotation)

Add a rotation to the object. Must be in XYZ order, euler angles, radians.

property rotation_euler: mathutils.Euler

Rotation in euler XYZ angles

scale_by(scale)

Scale object

set_dimensions(dimensions, frame=None)

Set dimensions of object.

Parameters:
  • dimensions (VectorLikeOrScalar) – Dimensions to set. Either single value or 3 long vector

  • frame (int) – Optional frame for animating

set_location(location, frame=None)

Set location of object.

Parameters:
  • location (VectorLike) – Location vector to set

  • frame (int) – Optional frame for animating

set_rotation_euler(rotation, frame=None)

Set euler rotation of object.

Parameters:
  • rotation (VectorLike) – Rotation vector

  • frame (int) – Optional frame for animating

set_scale(scale, frame=None)

Set scale of object.

Parameters:
  • scale (VectorLikeOrScalar) – Scale to set. Either single value or 3 long vector

  • frame (int) – Optional frame for animating

track_to(obj)

Track to object.

Parameters:

obj (Union[BsynObject, Object]) – BsynObject or Blender Object to track to

translate(translation)

Translate object

untrack()

Remove track to constraint from object

viewport_visibility(value, frame=None)

Show/hide object in viewport

Parameters:
  • value (bool) – True to show, False to hide

  • frame (int) – Optional frame for animating

class blendersynth.blender.armature.BoneConstraint(pose_bone, constraint, empty)[source]

Generic pose bone constraint object

animate_path(frames=(0, 250), fracs=(0, 1))

Animate object along path.

Parameters:
  • frames (tuple) – tuple of keyframes to animate at - length N

  • fracs (tuple) – tuple of fractions along path to animate at - length N

property axes: ndarray

Return 3x3 rotation matrix (normalized) to represent axes

follow_path(path, zero=True, animate=True, frames=(0, 250), fracs=(0, 1))

Follow path, with optional animation setting.

Parameters:
  • path (Curve) – Curve object

  • zero (bool) – If True, set camera location to (0, 0, 0) [aligns camera with path]

  • animate (bool) – If True, animate camera along path

  • frames (tuple) – tuple of keyframes to animate at - length N

  • fracs (tuple) – tuple of fractions along path to animate at - length N

property location: mathutils.Vector

Location of object

property matrix_world

Return world matrix of object(s).

path_keyframe(frame, offset)

Set keyframe for camera path offset

Parameters:
  • frame (int) – Frame number

  • offset (float) – Offset fraction (0-1)

remove()[source]

Remove this constraint.

render_visibility(value, frame=None)

Show/hide object in render

Parameters:
  • value (bool) – True to show, False to hide

  • frame (int) – Optional frame for animating

rotate_by(rotation)

Add a rotation to the object. Must be in XYZ order, euler angles, radians.

property rotation_euler: mathutils.Euler

Rotation in euler XYZ angles

scale_by(scale)

Scale object

set_dimensions(dimensions, frame=None)

Set dimensions of object.

Parameters:
  • dimensions (VectorLikeOrScalar) – Dimensions to set. Either single value or 3 long vector

  • frame (int) – Optional frame for animating

set_location(location, frame=None)

Set location of object.

Parameters:
  • location (VectorLike) – Location vector to set

  • frame (int) – Optional frame for animating

set_rotation_euler(rotation, frame=None)

Set euler rotation of object.

Parameters:
  • rotation (VectorLike) – Rotation vector

  • frame (int) – Optional frame for animating

set_scale(scale, frame=None)

Set scale of object.

Parameters:
  • scale (VectorLikeOrScalar) – Scale to set. Either single value or 3 long vector

  • frame (int) – Optional frame for animating

track_to(obj)

Track to object.

Parameters:

obj (Union[BsynObject, Object]) – BsynObject or Blender Object to track to

translate(translation)

Translate object

untrack()

Remove track to constraint from object

viewport_visibility(value, frame=None)

Show/hide object in viewport

Parameters:
  • value (bool) – True to show, False to hide

  • frame (int) – Optional frame for animating

class blendersynth.blender.armature.PoseBone(object)[source]
animate_path(frames=(0, 250), fracs=(0, 1))

Animate object along path.

Parameters:
  • frames (tuple) – tuple of keyframes to animate at - length N

  • fracs (tuple) – tuple of fractions along path to animate at - length N

apply_global_rotation(axis='X', val=0.0, degrees=False)[source]

Equivalent to selecting the bone in Blender, and applying a global rotation about an axis

Parameters:
  • axis (str) – X, Y, or Z

  • val (float) – Rotation amount in radians

  • degrees – If true, rotation is given in degrees

property axes: ndarray

Return 3x3 rotation matrix (normalized) to represent axes

follow_path(path, zero=True, animate=True, frames=(0, 250), fracs=(0, 1))

Follow path, with optional animation setting.

Parameters:
  • path (Curve) – Curve object

  • zero (bool) – If True, set camera location to (0, 0, 0) [aligns camera with path]

  • animate (bool) – If True, animate camera along path

  • frames (tuple) – tuple of keyframes to animate at - length N

  • fracs (tuple) – tuple of fractions along path to animate at - length N

property head_location: mathutils.Vector

Gets the world location of the head (start) of the bone.

property local_rotation_euler: mathutils.Euler

Rotation of pose bone in local space (ignoring parent transforms)

property location: mathutils.Vector

Gets the world location of the head (start) of the bone.

property matrix_world

Return world matrix of object(s).

path_keyframe(frame, offset)

Set keyframe for camera path offset

Parameters:
  • frame (int) – Frame number

  • offset (float) – Offset fraction (0-1)

remove()

Delete .obj from bpy.data if it exists

render_visibility(value, frame=None)

Show/hide object in render

Parameters:
  • value (bool) – True to show, False to hide

  • frame (int) – Optional frame for animating

rotate_by(rotation)

Add a rotation to the object. Must be in XYZ order, euler angles, radians.

property rotation_euler: mathutils.Euler

Rotation of pose bone in world space

scale_by(scale)

Scale object

set_dimensions(dimensions, frame=None)

Set dimensions of object.

Parameters:
  • dimensions (VectorLikeOrScalar) – Dimensions to set. Either single value or 3 long vector

  • frame (int) – Optional frame for animating

set_location(location, frame=None)

Set location of object.

Parameters:
  • location (VectorLike) – Location vector to set

  • frame (int) – Optional frame for animating

set_rotation_euler(rotation, frame=None)

Set euler rotation of object.

Parameters:
  • rotation (VectorLike) – Rotation vector

  • frame (int) – Optional frame for animating

set_scale(scale, update=True, frame=None)

Set scale of pose bone.

Parameters:
  • scale (VectorLikeOrScalar) – Scale to set. Either single value or 3 long vector

  • update (bool) – Update the scene after setting

scale. For batch operations, can be faster to set this to False, and call bsyn.context.view_layer.update() after all operations.

Parameters:

frame (int) – Optional frame for animating

property tail_location: mathutils.Vector

Gets the world location of the tail (or end) of the bone.

track_to(obj)

Track to object.

Parameters:

obj (Union[BsynObject, Object]) – BsynObject or Blender Object to track to

translate(translation)

Translate object

untrack()

Remove track to constraint from object

viewport_visibility(value, frame=None)

Show/hide object in viewport

Parameters:
  • value (bool) – True to show, False to hide

  • frame (int) – Optional frame for animating