Skip to content

Custom Data

Read and write custom user data attached to elements.

Access this group through api.tapir.custom_data.

Commands

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

get_element_user_data

get_element_user_data(
    elements: list[ElementIdArrayItem],
    keys: None | list[str] = None,
) -> list[ElementUserData | ErrorItem]

Reads the values stored on elements by SetElementUserData: every key of each element, or only the given keys.

Parameters:

  • elements (list[ElementIdArrayItem]) –

    A list of elements.

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

    Optional. Only the pairs with these keys are returned; a key an element does not hold is left out of its pairs. When omitted, every pair stored on each element is returned.

Returns:

  • list[ElementUserData | ErrorItem] –

    One item per element, in the input order: the pairs stored on the element (none when the element holds no user data of Tapir), or an error when the element was not found or its data could not be read.

set_element_user_data

set_element_user_data(
    element_user_data: list[ElementUserDataUpdate],
) -> list[
    FailedExecutionResult | SuccessfulExecutionResult
]

Stores string values under keys on elements, for scripts to keep their own state per element (external database ids, sync timestamps, markers). The data is saved with the project as the user data of the Tapir add-on on the element and appears nowhere in the Archicad UI. The given keys are merged into what the element 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. One undo step per call; in a Teamwork project the element has to be reserved.

Parameters:

  • element_user_data (list[ElementUserDataUpdate]) –

    The elements with the key-value pairs to store on them. Each item needs userData, keysToDelete or both.

Returns:

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