human.animation

Inherits from PreviewCollectionContent

Class for applying animations from the Human Generator library.

Animations are stored as rig independent clips and retargeted to the rig of this human when set, see retarget.py. The result is a normal Blender action on the rig, which can be edited like any other animation. Animations can also be added as strips in the NLA editor, to chain or layer them.

When the human changes shape the actions are retargeted again, in place: only the channels of the animated bones are written again, other channels, the name and fake user of the action and the NLA strips using it are kept.

Attributes
actionOptional[bpy.types.Action]The active action created by Human Generator on the rig, if any.
stripslist[bpy.types.NlaStrip]NLA strips on the rig with an animation created by Human Generator.
actionslist[bpy.types.Action]All actions created by Human Generator on the rig, active and in strips.
is_activeboolTrue if a Human Generator animation is on this human, active or in NLA.
loopboolTrue if the active animation repeats outside its frame range.
finger_curlfloatBlend of the fingers between the rest pose (0) and the animation (1).
frame_countintNumber of keyed frames of the active animation, 0 if there is none.
Methods
set()Optional[bpy.types.Action]Applies an animation from the Human Generator library to this human.
import_mixamo()strConverts a Mixamo FBX file to a clip in the library and applies it.
refresh()Retargets the Human Generator animations again, after the rig changed.
push_down()Optional[bpy.types.NlaStrip]Moves the active Human Generator animation to a strip in the NLA editor.
remove()Removes Human Generator animations from this human.
set_scene_frame_range()Sets the frame range of the scene to the Human Generator animation.
set_random()Set this content type to a random content item.from PreviewCollectionContent
get_options()List[str]Get a list of options you can use for the set() method of this content.from PreviewCollectionContent
get_categories()list[str]Get a list of categoris this content type is organized in.from PreviewCollectionContent
refresh_pcoll()Refresh the items of this preview collection.from PreviewCollectionContent
as_dict()Save these settings to a dict and restore them from one.

Attributes

human.animation.action: Optional[bpy.types.Action]read-only

source

The active action created by Human Generator on the rig, if any.

human.animation.strips: list[bpy.types.NlaStrip]read-only

source

NLA strips on the rig with an animation created by Human Generator.

human.animation.actions: list[bpy.types.Action]read-only

source

All actions created by Human Generator on the rig, active and in strips.

human.animation.is_active: boolread-only

source

True if a Human Generator animation is on this human, active or in NLA.

human.animation.loop: boolread-only

source

True if the active animation repeats outside its frame range.

human.animation.finger_curl: floatread-only

source

Blend of the fingers between the rest pose (0) and the animation (1).

human.animation.frame_count: intread-only

source

Number of keyed frames of the active animation, 0 if there is none.

Methods

human.animation.set(preset: str, context: C = None, loop: Optional[bool] = None, set_frame_range: bool = True, finger_curl: float = DEFAULT_FINGER_CURL, as_strip: bool = False, frame_start: Optional[int] = None) → Optional[bpy.types.Action]

source

Applies an animation from the Human Generator library to this human.

By default the animation becomes the active action of the rig, replacing the active Human Generator animation set before, and the pose of the body. The pose of the face rig is kept. Keys are placed on whole scene frames, resampled if the frame rate of the clip differs from the scene.

With as_strip the animation is added as a strip in the NLA editor instead, after the last strip added this way. An active Human Generator animation is pushed down to a strip first, so the new one is visible.

ParameterTypeDescription
presetstrName of the animation to set, you can get options from the `get_options` method.
contextC
default None
Context to use. Defaults to None.
loopOptional[bool]
default None
Repeat the animation outside its frame range. Defaults to the setting of the clip, True for cyclic animations.
set_frame_rangebool
default True
Set the frame range of the scene to the animation. Defaults to True. Ignored for strips.
finger_curlfloat
default DEFAULT_FINGER_CURL
Blend of the fingers between the relaxed hand of the rest pose (0) and the hand of the animation (1). Defaults to 1.0.
as_stripbool
default False
Add as NLA strip instead of as active action. Defaults to False.
frame_startOptional[int]
default None
Scene frame of the first key. Defaults to the start frame of the scene, for strips to the end of the last Human Generator strip.

Returns Optional[bpy.types.Action] — Optional[bpy.types.Action]: The created action, None if preset is "none".

Raises HumGenException — If the human has a Rigify rig.

human.animation.import_mixamo(filepath: str, name: Optional[str] = None, category: str = 'Mixamo', loop: bool = False, context: C = None, render_thumbnail: bool = True, finger_curl: float = DEFAULT_FINGER_CURL) → str

source

Converts a Mixamo FBX file to a clip in the library and applies it.

The clip is saved as json in the animations folder of the content folder, so it shows up in the animation library and can be used on other humans too. See mixamo.py for the conversion.

ParameterTypeDescription
filepathstrPath of the FBX file downloaded from Mixamo.
nameOptional[str]
default None
Name of the animation in the library. Defaults to the name of the file.
categorystr
default 'Mixamo'
Folder of the animation library to save the clip in, created if it does not exist. Defaults to "Mixamo".
loopbool
default False
Mark the animation as cyclic. Defaults to False.
contextC
default None
Context to use. Defaults to None.
render_thumbnailbool
default True
Render a thumbnail of this human in the animation next to the clip. Defaults to True.
finger_curlfloat
default DEFAULT_FINGER_CURL
See `set`. Defaults to 1.0.

Returns str — Preset path of the new animation, relative to the content folder.

Raises HumGenException — If the file is not a Mixamo animation or the human has a Rigify rig.

human.animation.refresh(context: C = None, finger_curl: Optional[float] = None)

source

Retargets the Human Generator animations again, after the rig changed.

Needed after changes to the height, proportions or rest pose of the human. The actions are updated in place, see the class docstring, and keep their timing: the frame they start on and their length.

ParameterTypeDescription
contextC
default None
Context to use. Defaults to None.
finger_curlOptional[float]
default None
New finger curl factor for the active animation, see `set`. Defaults to the factor it has. Animations in NLA strips keep their own factor.

human.animation.push_down() → Optional[bpy.types.NlaStrip]

source

Moves the active Human Generator animation to a strip in the NLA editor.

Like the push down button of Blender. The action keeps its frame range and is no longer the active action, so another animation can be set or added on top of it.

Returns Optional[bpy.types.NlaStrip] — Optional[bpy.types.NlaStrip]: The new strip, None if the human has no active Human Generator animation.

human.animation.remove(active: bool = True, strips: bool = False)

source

Removes Human Generator animations from this human.

The animated bones return to their rest position. Actions are deleted unless they are still used, by an NLA strip or a fake user.

ParameterTypeDescription
activebool
default True
Remove the active animation. Defaults to True.
stripsbool
default False
Remove the Human Generator animations in NLA strips and the tracks that become empty. Defaults to False.

human.animation.set_scene_frame_range(context: C = None)

source

Sets the frame range of the scene to the Human Generator animation.

One cycle of the active animation, or the range of all Human Generator strips if there is no active animation.

ParameterTypeDescription
contextC
default None
Context to use. Defaults to None.

human.animation.set_random(context: C = None, update_ui: bool = False)from PreviewCollectionContent

source

Set this content type to a random content item.

This will use random.choice to select a random item from the output of get_options().

ParameterTypeDescription
contextC
default None
Blender context. bpy.context if not provided.
update_uibool
default False
Will also show the chosen item as the active thumbnail in the template_icon_view. Defaults to False.

human.animation.get_options(context: C = None, category: str = 'All') → List[str]from PreviewCollectionContent

source

Get a list of options you can use for the set() method of this content.

These represent the choises the user sees in the UI. The output is a list of relative paths to the content files, starting from the Human Generator folder.

ParameterTypeDescription
contextC
default None
Blender context. bpy.context if not provided.
categorystr
default 'All'
Category to filter the content by. Defaults to "All". You can get a list of categories from the get_categories() method.

Returns List[str] — List[str]: List of relative paths to content files. You can pick one of these and pass it to the set() method.

Raises ValueError — If the passed category is not present in the list of categories.

Raises HumGenException — If no options can be found, this can be caused by the content pack for this type of content not being installed.

human.animation.get_categories() → list[str]from PreviewCollectionContent

source

Get a list of categoris this content type is organized in.

You can choose one of these categories to filter the content retreived from get_options().

Returns list[str] — list[str]: List of categories. These are the names of the folders the content is saved in.

human.animation.refresh_pcoll(context: C = None, override_category: Optional[str] = None, ignore_searchterm: bool = False)from PreviewCollectionContent

source

Refresh the items of this preview collection.

This is low level functionality, you should not need to use this. It is used to refresh the list of possible content for this human. If you use get_options() this is automatically done for you.

ParameterTypeDescription
contextC
default None
Blender context. bpy.context if not provided.
override_categoryOptional[str]
default None
Override the category to use, if not provided all items regardless of category will be shown.
ignore_searchtermbool
default False
If True, the searchterm set by the user will be ignored. Defaults to False.
Serialization: as_dict

human.animation.as_dict() → dict[str, Any]

source

Animation settings as dict.

Returns dict[str, Any] — dict[str, Any]: Animation settings as dict.