unreal.RigHierarchyController

class unreal.RigHierarchyController(outer=None, name='None')

Bases: unreal.Object

Rig Hierarchy Controller

C++ Source:

  • Plugin: ControlRig

  • Module: ControlRig

  • File: RigHierarchyController.h

add_bone(name, parent, transform, transform_in_global=True, bone_type=RigBoneType.USER, setup_undo=False, print_python_command=False) RigElementKey

Adds a bone to the hierarchy

Parameters
  • name (Name) – The suggested name of the new bone - will eventually be corrected by the namespace

  • parent (RigElementKey) – The (optional) parent of the new bone. If you don’t need a parent, pass FRigElementKey()

  • transform (Transform) – The transform for the new bone - either in local or global space, based on bTransformInGlobal

  • transform_in_global (bool) – Set this to true if the Transform passed is expressed in global space, false for local space.

  • bone_type (RigBoneType) – The type of bone to add. This can be used to differentiate between imported bones and user defined bones.

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

The key for the newly created bone.

Return type

RigElementKey

add_control(name, parent, settings, value, setup_undo=True) RigElementKey

Adds a control to the hierarchy

Parameters
  • name (Name) – The suggested name of the new control - will eventually be corrected by the namespace

  • parent (RigElementKey) – The (optional) parent of the new control. If you don’t need a parent, pass FRigElementKey()

  • settings (RigControlSettings) – All of the control’s settings

  • value (RigControlValue) – The value to use for the control

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

Returns

The key for the newly created control.

Return type

RigElementKey

add_curve(name, value=0.000000, setup_undo=True, print_python_command=False) RigElementKey

Adds a curve to the hierarchy

Parameters
  • name (Name) – The suggested name of the new curve - will eventually be corrected by the namespace

  • value (float) – The value to use for the curve

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

The key for the newly created curve.

Return type

RigElementKey

add_null(name, parent, transform, transform_in_global=True, setup_undo=False, print_python_command=False) RigElementKey

Adds a null to the hierarchy

Parameters
  • name (Name) – The suggested name of the new null - will eventually be corrected by the namespace

  • parent (RigElementKey) – The (optional) parent of the new null. If you don’t need a parent, pass FRigElementKey()

  • transform (Transform) – The transform for the new null - either in local or global null, based on bTransformInGlobal

  • transform_in_global (bool) – Set this to true if the Transform passed is expressed in global null, false for local null.

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

The key for the newly created null.

Return type

RigElementKey

add_parent(child, parent, weight=0.000000, maintain_global_transform=True, setup_undo=False) bool

Adds a new parent to an element. For elements that allow only one parent the parent will be replaced (Same as ::SetParent).

Parameters
  • child (RigElementKey) – The key of the element to add the parent for

  • parent (RigElementKey) – The key of the new parent to add

  • weight (float) – The initial weight to give to the parent

  • maintain_global_transform (bool) – If set to true the child will stay in the same place spatially, otherwise it will maintain it’s local transform (and potential move).

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

Returns

Returns true if successful.

Return type

bool

add_rigid_body(name, parent, settings, local_transform, setup_undo=False, print_python_command=False) RigElementKey

Adds a rigidbody to the hierarchy

Parameters
  • name (Name) – The suggested name of the new rigidbody - will eventually be corrected by the namespace

  • parent (RigElementKey) – The (optional) parent of the new rigidbody. If you don’t need a parent, pass FRigElementKey()

  • settings (RigRigidBodySettings) – All of the rigidbody’s settings

  • local_transform (Transform) – The transform for the new rigidbody - in the space of the provided parent

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

The key for the newly created rigidbody.

Return type

RigElementKey

clear_selection() bool

Clears the selection

Returns

Returns true if the selection was applied

Return type

bool

deselect_element(key) bool

Deselects or deselects an element in the hierarchy

Parameters

key (RigElementKey) – The key of the element to deselect

Returns

Returns true if the selection was applied

Return type

bool

duplicate_elements(keys, select_new_elements=True, setup_undo=False, print_python_commands=False)

Duplicate the given elements

Parameters
  • keys (Array(RigElementKey)) – The keys of the elements to duplicate

  • select_new_elements (bool) – If set to true the new elements will be selected

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_commands (bool) –

Returns

The keys of the 4d items

Return type

Array(RigElementKey)

export_selection_to_text() str

Exports the selected items to text

Returns

The text representation of the selected items

Return type

str

export_to_text(keys) str

Exports a list of items to text

Parameters

keys (Array(RigElementKey)) – The keys to export to text

Returns

The text representation of the requested elements

Return type

str

generate_python_commands()

Generate Python Commands

Return type

Array(str)

get_control_settings(key) RigControlSettings

Returns the control settings of a given control

Parameters

key (RigElementKey) – The key of the control to receive the settings for

Returns

The settings of the given control

Return type

RigControlSettings

get_hierarchy() RigHierarchy

Returns the hierarchy currently linked to this controller

Return type

RigHierarchy

import_bones(skeleton, name_space='None', replace_existing_bones=True, remove_obsolete_bones=True, select_bones=False, setup_undo=False, print_python_command=False)

Imports an existing skeleton to the hierarchy

Parameters
  • skeleton (Skeleton) – The skeleton to import

  • name_space (Name) – The namespace to prefix the bone names with

  • replace_existing_bones (bool) – If true existing bones will be removed

  • remove_obsolete_bones (bool) – If true bones non-existent in the skeleton will be removed from the hierarchy

  • select_bones (bool) – If true the bones will be selected upon import

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

The keys of the imported elements

Return type

Array(RigElementKey)

import_bones_from_asset(asset_path, name_space='None', replace_existing_bones=True, remove_obsolete_bones=True, select_bones=False, setup_undo=False)

Imports an existing skeleton to the hierarchy

Parameters
  • asset_path (str) – The path to the uasset to import from

  • name_space (Name) – The namespace to prefix the bone names with

  • replace_existing_bones (bool) – If true existing bones will be removed

  • remove_obsolete_bones (bool) – If true bones non-existent in the skeleton will be removed from the hierarchy

  • select_bones (bool) – If true the bones will be selected upon import

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

Returns

The keys of the imported elements

Return type

Array(RigElementKey)

import_curves(skeleton, name_space='None', select_curves=False, setup_undo=False, print_python_command=False)

Imports all curves from a skeleton to the hierarchy

Parameters
  • skeleton (Skeleton) – The skeleton to import the curves from

  • name_space (Name) – The namespace to prefix the bone names with

  • select_curves (bool) – If true the curves will be selected upon import

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) –

Returns

The keys of the imported elements

Return type

Array(RigElementKey)

import_curves_from_asset(asset_path, name_space='None', select_curves=False, setup_undo=False)

Imports all curves from a skeleton to the hierarchy

Parameters
  • asset_path (str) – The path to the uasset to import from

  • name_space (Name) – The namespace to prefix the bone names with

  • select_curves (bool) – If true the curves will be selected upon import

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

Returns

The keys of the imported elements

Return type

Array(RigElementKey)

import_from_text(content, replace_existing_elements=False, select_new_elements=True, setup_undo=False, print_python_commands=False)

Imports the content of a text buffer to the hierarchy

Parameters
  • content (str) – The string buffer representing the content to import

  • replace_existing_elements (bool) – If set to true existing items will be replaced / updated with the content in the buffer

  • select_new_elements (bool) – If set to true the new elements will be selected

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_commands (bool) –

Return type

Array(RigElementKey)

mirror_elements(keys, settings, select_new_elements=True, setup_undo=False, print_python_commands=False)

Mirrors the given elements

Parameters
  • keys (Array(RigElementKey)) – The keys of the elements to mirror

  • settings (RigMirrorSettings) – The settings to use for the mirror operation

  • select_new_elements (bool) – If set to true the new elements will be selected

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_commands (bool) –

Returns

The keys of the mirrored items

Return type

Array(RigElementKey)

remove_all_parents(child, maintain_global_transform=True, setup_undo=False, print_python_command=False) bool

Removes all parents from an element in the hierarchy.

Parameters
  • child (RigElementKey) – The key of the element to remove all parents for

  • maintain_global_transform (bool) – If set to true the child will stay in the same place spatially, otherwise it will maintain it’s local transform (and potential move).

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

Returns true if successful.

Return type

bool

remove_element(element, setup_undo=False, print_python_command=False) bool

Removes an existing element from the hierarchy

Parameters
  • element (RigElementKey) – The key of the element to remove

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

Returns true if successful.

Return type

bool

remove_parent(child, parent, maintain_global_transform=True, setup_undo=False, print_python_command=False) bool

Removes an existing parent from an element in the hierarchy. For elements that allow only one parent the element will be unparented (same as ::RemoveAllParents)

Parameters
  • child (RigElementKey) – The key of the element to remove the parent for

  • parent (RigElementKey) – The key of the parent to remove

  • maintain_global_transform (bool) – If set to true the child will stay in the same place spatially, otherwise it will maintain it’s local transform (and potential move).

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

Returns true if successful.

Return type

bool

rename_element(element, name, setup_undo=False, print_python_command=False, clear_selection=True) RigElementKey

Renames an existing element in the hierarchy

Parameters
  • element (RigElementKey) – The key of the element to rename

  • name (Name) – The new name to set for the element

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

  • clear_selection (bool) – True if the selection should be cleared after a rename

Returns

Returns the new element key used for the element

Return type

RigElementKey

select_element(key, select=True, clear_selection=False) bool

Selects or deselects an element in the hierarchy

Parameters
  • key (RigElementKey) – The key of the element to select

  • select (bool) – If set to false the element will be deselected

  • clear_selection (bool) –

Returns

Returns true if the selection was applied

Return type

bool

set_control_settings(key, settings, setup_undo=False) bool

Sets a control’s settings given a control key

Parameters
Returns

Returns true if the settings have been set correctly

Return type

bool

set_hierarchy(hierarchy) None

Sets the hierarchy currently linked to this controller

Parameters

hierarchy (RigHierarchy) –

set_parent(child, parent, maintain_global_transform=True, setup_undo=False, print_python_command=False) bool

Sets a new parent to an element. For elements that allow more than one parent the parent list will be replaced.

Parameters
  • child (RigElementKey) – The key of the element to set the parent for

  • parent (RigElementKey) – The key of the new parent to set

  • maintain_global_transform (bool) – If set to true the child will stay in the same place spatially, otherwise it will maintain it’s local transform (and potential move).

  • setup_undo (bool) – If set to true the stack will record the change for undo / redo

  • print_python_command (bool) – If set to true a python command equivalent to this call will be printed out

Returns

Returns true if successful.

Return type

bool

set_selection(keys, print_python_command=False) bool

Sets the selection based on a list of keys

Parameters
Returns

Returns true if the selection was applied

Return type

bool