blenderproc.python.types.BoneUtility module

Utility functions to manage the connections between nodes.

blenderproc.python.types.BoneUtility.add_constraint_if_not_existing(bone, constraint_name='', custom_constraint_name=None, add_to_existing=False)[source]

Adds a new constraint.

Parameters:
  • bone (PoseBone) – The bone to add the constraint to.

  • constraint_name (str) – Name of the desired constraint.

  • custom_constraint_name (Optional[str]) – Custom name for the constraint. If not specified will use the default name.

  • add_to_existing (bool) – If true, will add a new constraint even if a constraint of the same type already exists.

Return type:

Optional[Constraint]

Returns:

The created constraint or None if it already exists and add_to_existing=False.

blenderproc.python.types.BoneUtility.copy_constraints(source_bone, target_bone, constraints_to_be_copied=None)[source]

Copies constraints from one bone to another.

Parameters:
  • source_bone (PoseBone) – The bone holding the constraints to be copied.

  • target_bone (PoseBone) – The bone where the constraints should be copied to.

  • constraints_to_be_copied (Optional[List[str]]) – A list of constraints to copy if not all constraints should be copied.

blenderproc.python.types.BoneUtility.get_armature_from_bone(bone_name)[source]

Returns the armature that holds a specified bone.

Parameters:

bone_name (str) – Name of the bone.

Return type:

Optional[MeshObject]

Returns:

The respective armature.

blenderproc.python.types.BoneUtility.get_constraint(bone, constraint_name='')[source]

Returns the desired constraint if existing; otherwise None.

Parameters:
  • bone (PoseBone) – The bone to set the constraint to.

  • constraint_name (str) – Name of the constraint.

Return type:

Optional[Constraint]

Returns:

Constraint if it exists; else None.

blenderproc.python.types.BoneUtility.get_location_constraint(bone)[source]

Returns the location constraint if existing; otherwise None.

Parameters:

bone (PoseBone) – The bone to set the constraint to.

Return type:

Optional[Constraint]

Returns:

Location constraint if it exists; else None.

blenderproc.python.types.BoneUtility.get_rotation_constraint(bone)[source]

Returns the rotation constraint if existing; otherwise None.

Parameters:

bone (PoseBone) – The bone to set the constraint to.

Return type:

Optional[Constraint]

Returns:

Rotation constraint if it exists; else None.

blenderproc.python.types.BoneUtility.remove_constraint(bone, constraint_key='')[source]

Removes a specified constraint.

Parameters:
  • bone (PoseBone) – The bone to set the constraint to.

  • constraint_key (str) – Key to be removed.

blenderproc.python.types.BoneUtility.remove_constraints(bone)[source]

Removes all constraints of the armature.

Parameters:

bone (PoseBone) – The bone to set the constraint to.

blenderproc.python.types.BoneUtility.set_copy_location_constraint(bone, target, target_bone, custom_constraint_name=None, influence=1.0, target_space='LOCAL', owner_space='LOCAL')[source]

Sets a copy_location constraint.

Parameters:
  • bone (PoseBone) – The bone to set the constraint to.

  • target (Armature) – The armature holding the bone.

  • target_bone (str) – Name of the target bone which locations shall influence this bone.

  • custom_constraint_name (Optional[str]) – Custom name for the constraint. If not specified will use the default name.

  • influence (float) – Influence of the constraint.

  • target_space (str) – Target space of the constraint.

  • owner_space (str) – Owner space of the constraint.

blenderproc.python.types.BoneUtility.set_copy_rotation_constraint(bone, target, target_bone, custom_constraint_name=None, influence=1.0)[source]

Sets a copy_rotation constraint.

Parameters:
  • bone (PoseBone) – The bone to set the constraint to.

  • target (PoseBone) – The armature holding the bone.

  • target_bone (str) – Name of the target bone which rotations shall influence this bone.

  • custom_constraint_name (Optional[str]) – Custom name for the constraint. If not specified will use the default name.

  • influence (float) – Influence of the constraint.

blenderproc.python.types.BoneUtility.set_ik_constraint(bone, target, target_bone, influence=1.0, use_rotation=True, chain_length=0)[source]

Sets an inverse kinematics constraint.

Parameters:
  • bone (PoseBone) – The bone to set the constraint to.

  • target (Armature) – The armature holding the bone.

  • target_bone (str) – Name of the target bone which movements shall influence this bone.

  • influence (float) – Influence of the constraint.

  • use_rotation (bool) – Whether to rotate the child links as well. Defaults to True.

  • chain_length (int) – The number of parent links which are influenced by this ik bone. Defaults to 0 for all parents.

blenderproc.python.types.BoneUtility.set_ik_limits_from_rotation_constraint(bone, constraint=None)[source]

Sets inverse kinematics limits based on a given rotation constraint.

Parameters:
  • bone (PoseBone) – The bone to set the inverse kinematics limits to.

  • constraint (Optional[Constraint]) – The rotation constraint. If None tries to determine it automatically from the bone.

blenderproc.python.types.BoneUtility.set_location_constraint(bone, x_limits=None, y_limits=None, z_limits=None)[source]

Sets a location constraint.

Parameters:
  • bone (PoseBone) – The bone to set the constraint to.

  • x_limits (Optional[List[float]]) – A list of two float values specifying min/max values along the x-axis or None if no constraint should be applied.

  • y_limits (Optional[List[float]]) – A list of two float values specifying min/max values along the y-axis or None if no constraint should be applied.

  • z_limits (Optional[List[float]]) – A list of two float values specifying min/max values along the z-axis or None if no constraint should be applied.

blenderproc.python.types.BoneUtility.set_rotation_constraint(bone, x_limits=None, y_limits=None, z_limits=None, set_ik_limits=True)[source]

Sets rotation constraints on the armature’s bone.

Parameters:
  • bone (PoseBone) – The bone to set the constraint to.

  • x_limits (Optional[List[float]]) – A list of two float values specifying min/max radiant values along the x-axis or None if no constraint should be applied.

  • y_limits (Optional[List[float]]) – A list of two float values specifying min/max radiant values along the y-axis or None if no constraint should be applied.

  • z_limits (Optional[List[float]]) – A list of two float values specifying min/max radiant values along the z-axis or None if no constraint should be applied.

  • set_ik_limits (bool) – If true will set inverse kinematics constraints based on the allowed rotation axis.