Skip to content

Script UI

Ask users for input through Archicad dialogs, pickers and Tapir script interfaces.

Access this group through api.tapir.script_ui.

Commands

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

get_script_ui_result

get_script_ui_result(
    *,
    ui_id: None | int = None,
    script_id: None | str = None,
) -> GetScriptUIResultResult

Retrieves and clears the result last submitted from a Script UI window's page (via window.ACAPI.SubmitResult), if any, and reports whether the window is still open, so a waiting script can stop when the user closes it. The window is picked by uiId or scriptId; without them the first window is used.

Parameters:

  • ui_id (None | int, default: None ) –

    The window to use, as returned by ShowScriptUI (1 to 8). Takes precedence over scriptId.

  • script_id (None | str, default: None ) –

    Any text that identifies the calling script, so it uses its own window: ShowScriptUI gives a script without a window a free one, preferring the closed windows. The Tapir palette gives each script it starts its own id in the TAPIR_SCRIPT_ID environment variable, which aclib passes here automatically; that script's window is titled with its name and is freed when it ends. Without uiId and scriptId the first window is used.

Returns:

open_settings_dialog

open_settings_dialog(
    element_type: ElementType | None = None,
) -> bool

Opens Archicad's settings dialog of the selected elements or the current tool (Archicad 28 and later), or the default settings dialog of the given element type, waits for the user and reports whether the dialog was closed with OK or Cancel.

Parameters:

  • element_type (ElementType | None, default: None ) –

    Opens the default settings dialog of this tool. Without it, Archicad 28 and later open the settings of the selected elements, or of the current tool when nothing is selected; Archicad 25 to 27 open the default settings of the current tool.

Returns:

  • bool –

    True when the user closed the dialog with Cancel, false when with OK.

pick_attribute

pick_attribute(
    attribute_type: PickableAttributeType,
    attribute_id: AttributeId | None = None,
    title: None | str = None,
) -> PickAttributeResult

Opens a small dialog with Archicad's attribute picker for the given attribute type (layer, building material, composite, profile or surface; fill and line from Archicad 27), waits for the user and returns the chosen attribute, or cancelled. Available from Archicad 26.

Parameters:

  • attribute_type (PickableAttributeType) –

    The type of the attribute to pick. Fill and Line need Archicad 27 or newer. Composite lists the composites only.

  • attribute_id (AttributeId | None, default: None ) –

    The attribute selected when the dialog opens. Without it the picker starts empty and OK is enabled once the user has picked an attribute.

  • title (None | str, default: None ) –

    The title of the dialog. Default: Pick Attribute.

Returns:

pick_attribute_folder

pick_attribute_folder(
    attribute_type: PickableAttributeType,
    title: None | str = None,
) -> PickAttributeFolderResult

Opens a small dialog with Archicad's attribute folder picker for the given attribute type, waits for the user and returns the chosen folder as its path from the root folder, or cancelled. Available from Archicad 26.

Parameters:

  • attribute_type (PickableAttributeType) –
  • title (None | str, default: None ) –

    The title of the dialog. Default: Pick Attribute Folder.

Returns:

pick_library_folder

pick_library_folder(
    default_name: None | str = None,
) -> PickLibraryFolderResult

Opens Archicad's dialog for choosing or creating a library folder, waits for the user and returns the location of the folder, or reports that the user cancelled. The folder is not added to the libraries of the project.

Parameters:

  • default_name (None | str, default: None ) –

    The default name the dialog offers for a new library folder. Default: New Library.

Returns:

pick_library_part

pick_library_part(
    element_type: LibraryPartPickerElementType
    | None = None,
    subtype_un_id: None | str = None,
) -> PickLibraryPartResult

Opens Archicad's Object, Lamp, Window or Door Settings dialog, optionally limited to a library part subtype, lets the user pick a library part and set its parameters, and returns the chosen library part with its GDL parameters, or that the user cancelled. Places nothing.

Parameters:

  • element_type (LibraryPartPickerElementType | None, default: None ) –

    Without a subtypeUnID the dialog lists the library parts of that tool. Object by default.

  • subtype_un_id (None | str, default: None ) –

    Limits the dialog to the library parts of this subtype: the unique ID of the subtype library part, its main and revision GUID in the form {main}-{revision}.

Returns:

pick_library_part_file

pick_library_part_file(
    general_gdl_objects_only: None | bool = None,
) -> PickLibraryPartFileResult

Opens Archicad's Open Library Part dialog, waits for the user and returns the location of the chosen library part, or reports that the user cancelled.

Parameters:

  • general_gdl_objects_only (None | bool, default: None ) –

    Sets the dialog's file filter to General GDL Objects. Default: false.

Returns:

pick_library_part_save_location

pick_library_part_save_location(
    default_path: None | str = None,
    library_part_type: LibraryPartSaveLocationType
    | None = None,
    browse_for_folder: None | bool = None,
    title: None | str = None,
) -> PickLibraryPartSaveLocationResult

Opens Archicad's Save Library Part dialog (object, door or window), waits for the user and returns the location chosen to save the library part to, or reports that the user cancelled. Nothing is saved.

Parameters:

  • default_path (None | str, default: None ) –

    The location (library folder and file name) the dialog starts from. Default: .gsm in the embedded library of the project.

  • library_part_type (LibraryPartSaveLocationType | None, default: None ) –

    Default: Object.

  • browse_for_folder (None | bool, default: None ) –

    Lets the user save outside the embedded library. Default: false.

  • title (None | str, default: None ) –

    The title of the dialog. Default: Archicad's own title.

Returns:

pick_picture_file

pick_picture_file() -> PickPictureFileResult

Opens Archicad's Open Picture dialog (the one of the texture settings), waits for the user and returns the location of the chosen picture, or reports that the user cancelled. Archicad adds the chosen picture to the embedded library when it is not in it yet.

Returns:

pick_zone_stamp_or_label_file

pick_zone_stamp_or_label_file(
    object_type: None | ObjectType = None,
) -> PickZoneStampOrLabelFileResult

Opens Archicad's dialog for opening a zone stamp or label library part, waits for the user and returns the location of the chosen file, or reports that the user cancelled.

Parameters:

  • object_type (None | ObjectType, default: None ) –

    The type of library part the dialog lets the user open. Default: Label.

Returns:

show_ifc_export_settings

show_ifc_export_settings(
    navigator_item_id: NavigatorItemId | None = None,
    translator_name: None | str = None,
) -> ShowIFCExportSettingsResult

Opens Archicad's IFC export settings dialog, where the user picks a view and an IFC export translator, waits for the user and returns the chosen view and translator, or cancelled. Available from Archicad 28.

Parameters:

  • navigator_item_id (NavigatorItemId | None, default: None ) –

    Optional: the view (an item of the View Map) the dialog starts with.

  • translator_name (None | str, default: None ) –

    Optional: the name of the IFC export translator the dialog starts with, as GetIFCExportTranslators lists them.

Returns:

show_script_ui

show_script_ui(
    html_content: str,
    width: None | int = None,
    height: None | int = None,
    title: None | str = None,
    resizable: None | bool = None,
    zoom_enabled: None | bool = None,
    zoom_level: None | float = None,
    scroll_bars_visible: None | bool = None,
    context_menu_enabled: None | bool = None,
    navigation_disabled: None | bool = None,
    allow_self_signed_certificates: None | bool = None,
    clear_cookies: None | bool = None,
    auto_height: None | bool = None,
    *,
    ui_id: None | int = None,
    script_id: None | str = None,
) -> ScriptUIShown

Shows the given HTML content in a native Archicad palette (a tkinter alternative for Python scripts) and returns the uiId of its window. Each script can have its own window, picked by uiId or scriptId; without them the first window is used.

Parameters:

  • html_content (str) –

    The full HTML document to display in the Script UI palette.

  • width (None | int, default: None ) –

    Optional palette client width in pixels. Leave unset to keep the current size.

  • height (None | int, default: None ) –

    Optional palette client height in pixels. Leave unset to keep the current size.

  • title (None | str, default: None ) –

    Optional palette window title. Leave unset to keep the current title.

  • resizable (None | bool, default: None ) –

    Whether the user can drag-resize the palette. Defaults to true.

  • zoom_enabled (None | bool, default: None ) –

    Whether Ctrl+scroll/pinch zooming is allowed in the page. Defaults to true.

  • zoom_level (None | float, default: None ) –

    Optional initial zoom level (1.0 = 100%). Leave unset to keep the current zoom.

  • scroll_bars_visible (None | bool, default: None ) –

    Whether the browser's own scrollbars are shown. Defaults to true.

  • context_menu_enabled (None | bool, default: None ) –

    Whether right-click shows the browser's context menu (e.g. Inspect Element). Defaults to true.

  • navigation_disabled (None | bool, default: None ) –

    Prevents the page from navigating away (e.g. clicking a link to another site) once it has loaded. Defaults to false.

  • allow_self_signed_certificates (None | bool, default: None ) –

    Only relevant if htmlContent links to a remote https:// resource with a self-signed certificate. Defaults to false.

  • clear_cookies (None | bool, default: None ) –

    Deletes all browser cookies before loading htmlContent. Defaults to false.

  • auto_height (None | bool, default: None ) –

    Automatically resizes the palette's height to fit the page content as it changes. Defaults to false.

  • ui_id (None | int, default: None ) –

    The window to use, as returned by ShowScriptUI (1 to 8). Takes precedence over scriptId.

  • script_id (None | str, default: None ) –

    Any text that identifies the calling script, so it uses its own window: ShowScriptUI gives a script without a window a free one, preferring the closed windows. The Tapir palette gives each script it starts its own id in the TAPIR_SCRIPT_ID environment variable, which aclib passes here automatically; that script's window is titled with its name and is freed when it ends. Without uiId and scriptId the first window is used.

Returns:

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