AnimationSettings
human/animation/animation.pyInherits 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 | ||
|---|---|---|
| action | Optional[bpy.types.Action] | The active action created by Human Generator on the rig, if any. |
| strips | list[bpy.types.NlaStrip] | NLA strips on the rig with an animation created by Human Generator. |
| actions | list[bpy.types.Action] | All actions created by Human Generator on the rig, active and in strips. |
| is_active | bool | True if a Human Generator animation is on this human, active or in NLA. |
| loop | bool | True if the active animation repeats outside its frame range. |
| finger_curl | float | Blend of the fingers between the rest pose (0) and the animation (1). |
| frame_count | int | Number 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() | str | Converts 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
The active action created by Human Generator on the rig, if any.
NLA strips on the rig with an animation created by Human Generator.
All actions created by Human Generator on the rig, active and in strips.
True if a Human Generator animation is on this human, active or in NLA.
True if the active animation repeats outside its frame range.
human.animation.finger_curl: floatread-only
sourceBlend of the fingers between the rest pose (0) and the animation (1).
human.animation.frame_count: intread-only
sourceNumber 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]
sourceApplies 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.
| Parameter | Type | Description |
|---|---|---|
| preset | str | Name of the animation to set, you can get options from the `get_options` method. |
| context | C default None | Context to use. Defaults to None. |
| loop | Optional[bool] default None | Repeat the animation outside its frame range. Defaults to the setting of the clip, True for cyclic animations. |
| set_frame_range | bool default True | Set the frame range of the scene to the animation. Defaults to True. Ignored for strips. |
| finger_curl | float 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_strip | bool default False | Add as NLA strip instead of as active action. Defaults to False. |
| frame_start | Optional[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
sourceConverts 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.
| Parameter | Type | Description |
|---|---|---|
| filepath | str | Path of the FBX file downloaded from Mixamo. |
| name | Optional[str] default None | Name of the animation in the library. Defaults to the name of the file. |
| category | str default 'Mixamo' | Folder of the animation library to save the clip in, created if it does not exist. Defaults to "Mixamo". |
| loop | bool default False | Mark the animation as cyclic. Defaults to False. |
| context | C default None | Context to use. Defaults to None. |
| render_thumbnail | bool default True | Render a thumbnail of this human in the animation next to the clip. Defaults to True. |
| finger_curl | float 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.
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.
| Parameter | Type | Description |
|---|---|---|
| context | C default None | Context to use. Defaults to None. |
| finger_curl | Optional[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. |
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.
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.
| Parameter | Type | Description |
|---|---|---|
| active | bool default True | Remove the active animation. Defaults to True. |
| strips | bool 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)
sourceSets 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.
| Parameter | Type | Description |
|---|---|---|
| context | C default None | Context to use. Defaults to None. |
human.animation.set_random(context: C = None, update_ui: bool = False)from PreviewCollectionContent
sourceSet this content type to a random content item.
This will use random.choice to select a random item from the output of get_options().
| Parameter | Type | Description |
|---|---|---|
| context | C default None | Blender context. bpy.context if not provided. |
| update_ui | bool 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
sourceGet 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.
| Parameter | Type | Description |
|---|---|---|
| context | C default None | Blender context. bpy.context if not provided. |
| category | str 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
sourceGet 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
sourceRefresh 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.
| Parameter | Type | Description |
|---|---|---|
| context | C default None | Blender context. bpy.context if not provided. |
| override_category | Optional[str] default None | Override the category to use, if not provided all items regardless of category will be shown. |
| ignore_searchterm | bool default False | If True, the searchterm set by the user will be ignored. Defaults to False. |