Skip to content

Element grouping

Read and manage element groups and element sets, including group membership, group data and suspended-group mode.

Access this group through api.tapir.element_grouping.

Commands

For exceptions shared by Unified API commands, see error handling.

create_element_sets

create_element_sets(
    element_sets: list[ElementSetData],
) -> list[ElementSetIdArrayItem | ErrorItem]

Creates element sets of the given elements. An element set is a hidden, persistent collection of elements (it is not a group and has no effect on selection or editing).

Parameters:

Returns:

create_groups

create_groups(
    element_groups: list[ElementGroupParameters],
) -> list[ErrorItem | GroupIdArrayItem]

Creates groups of the passed elements

Parameters:

Returns:

delete_element_sets

delete_element_sets(
    element_sets: list[ElementSetIdArrayItem],
) -> list[
    FailedExecutionResult | SuccessfulExecutionResult
]

Deletes the given element sets. The elements of a set are not deleted. Only element sets created by the Tapir Add-On can be deleted; sets created by other add-ons are reported as failed. With dryRun true nothing is deleted and no undo step is created: the response has dryRun set to true, and each element set that a real run would delete gets wouldDelete.

Parameters:

  • element_sets (list[ElementSetIdArrayItem]) –

    The element sets to delete, as returned by CreateElementSets or GetElementSetsOfElements. Only element sets created by the Tapir Add-On can be deleted. The elements of a deleted set are not deleted.

Returns:

delete_element_sets_dry_run

delete_element_sets_dry_run(
    element_sets: list[ElementSetIdArrayItem],
) -> DeleteElementSetsResult

Preview this command without applying its changes. Deletes the given element sets. The elements of a set are not deleted. Only element sets created by the Tapir Add-On can be deleted; sets created by other add-ons are reported as failed. With dryRun true nothing is deleted and no undo step is created: the response has dryRun set to true, and each element set that a real run would delete gets wouldDelete.

Parameters:

  • element_sets (list[ElementSetIdArrayItem]) –

    The element sets to delete, as returned by CreateElementSets or GetElementSetsOfElements. Only element sets created by the Tapir Add-On can be deleted. The elements of a deleted set are not deleted.

Returns:

get_all_elements_of_groups

get_all_elements_of_groups(
    groups: list[GroupIdArrayItem],
) -> list[ElementsWrapper | ErrorItem]

Gets all the elements of each given group, including the elements of its nested groups.

Parameters:

Returns:

  • list[ElementsWrapper | ErrorItem] –

    All the elements of each given group, including the elements of its nested groups, or an error.

get_auto_group_mode

get_auto_group_mode() -> bool

Gets the current state of the Auto Group mode.

Returns:

  • bool –

    True if the Auto Group mode is currently on.

get_element_set_data

get_element_set_data(
    element_sets: list[ElementSetIdArrayItem],
) -> list[ElementSetDetails | ErrorItem]

Gets the elements and the custom data of each given element set. Element sets are created by add-ons to link elements together; the custom data is returned as Base64 encoded bytes.

Parameters:

Returns:

get_element_sets_of_elements

get_element_sets_of_elements(
    elements: list[ElementIdArrayItem],
) -> list[ElementSetsOfElement | ErrorItem]

Gets the element sets that contain each given element. Only element sets created by the Tapir Add-On are examined; sets created by other add-ons are not found.

Parameters:

Returns:

  • list[ElementSetsOfElement | ErrorItem] –

    The element sets that contain each given element, or an error, in the order of the input. Only element sets created by the Tapir Add-On are examined.

get_elements_of_groups

get_elements_of_groups(
    groups: list[GroupIdArrayItem],
) -> list[ElementsWrapper | ErrorItem]

Gets the elements directly contained by each given group.

Parameters:

Returns:

get_groups_of_elements

get_groups_of_elements(
    elements: list[ElementIdArrayItem],
) -> list[ErrorItem | GroupIdArrayItem]

Gets the identifier of the group that directly contains each given element. Returns an error for elements that are not part of any group.

Parameters:

Returns:

  • list[ErrorItem | GroupIdArrayItem] –

    The identifier of the group that directly contains each given element, or an error for elements that are not part of any group.

get_main_groups

get_main_groups(
    groups: list[GroupIdArrayItem],
) -> list[ErrorItem | GroupIdArrayItem]

Gets the top level group of each given group. A group that is not nested in another group is its own top level group.

Parameters:

Returns:

  • list[ErrorItem | GroupIdArrayItem] –

    The top level group of each given group (the group itself if it is not nested in another group), or an error.

get_suspend_groups_mode

get_suspend_groups_mode() -> bool

Gets the current state of the Suspend Groups mode.

Returns:

  • bool –

    True if the Suspend Groups mode is currently on.

get_user_data_of_groups

get_user_data_of_groups(
    groups: list[GroupIdArrayItem],
) -> list[ErrorItem | GroupUserDataResult]

Gets the user data an add-on attached to each given group: its version, platform sign, flags and bytes (base64 encoded), and, when its version is 1 (the layout SetUserDataOfGroups writes), its key-value pairs. Returns an error for groups that have no user data.

Parameters:

Returns:

set_suspend_groups_mode

set_suspend_groups_mode(
    suspend_groups: bool,
) -> FailedExecutionResult | SuccessfulExecutionResult

Turns the Suspend Groups mode on or off. Suspend groups to perform operations on elements that are part of a group; remember to restore the previous state afterwards.

Parameters:

  • suspend_groups (bool) –

    Turn the Suspend Groups mode on or off.

Returns:

set_user_data_of_groups

set_user_data_of_groups(
    groups: list[GroupIdArrayItem],
    pairs: None | list[UserDataPair] = None,
    keys_to_delete: None | list[str] = None,
) -> list[
    FailedExecutionResult | SuccessfulExecutionResult
]

Stores string values under keys in the user data of groups, for scripts to keep their own state on a group. The given pairs are merged into what each group already holds: a key that exists gets the new value, other keys are left as they are, and the keys listed in keysToDelete are removed. Prefix the keys with the script's name so that scripts do not overwrite each other's data. User data in another layout is left unchanged and reported as an error. One undo step per call.

Parameters:

  • groups (list[GroupIdArrayItem]) –

    The groups to store the pairs on.

  • pairs (None | list[UserDataPair], default: None ) –

    The key-value pairs to store on each group. A key the group already holds gets the new value; other keys are left as they are.

  • keys_to_delete (None | list[str], default: None ) –

    The keys to remove from the user data. A key that is not stored is ignored. Applied after pairs.

Returns:

ungroup_elements

ungroup_elements(
    groups: list[GroupIdArrayItem],
) -> list[
    FailedExecutionResult | SuccessfulExecutionResult
]

Ungroups the given groups one level, like Edit > Grouping > Ungroup: each group is dissolved, the elements and subgroups it directly contains stay. A group nested in another group is reported as failed; ungroup the containing group first. Returns an execution result per group.

Parameters:

  • groups (list[GroupIdArrayItem]) –

    The groups to ungroup, as returned by CreateGroups or GetGroupsOfElements. A group nested in another group is reported as failed: ungroup the containing group first.

Returns:

These include the parameter and result models used inside the client. The command signatures above show what to pass and what is returned.