Skip to content

Run property ingestion without a GUI

A command-line property pipeline can read Archicad and store the results in an application database. Its entry point owns configuration and transaction handling; a processor receives the selected header, and the reader receives an API client.

These excerpts adapt a property-ingestion workflow: acquire a header, read the selected elements in chunks, and pass their property rows to the database layer. They read Archicad without changing its model; they write to the application database. Database configuration, identity mapping, and SQL inserts are omitted.

Headless means the pipeline has no GUI. Archicad still needs to run for API commands and may show windows or dialogs.

Entry point: choose the project and own the transaction

In the application, a context holds configuration, logging, and database access. Here, ctx.conn_data is its database connection. ctx.store_rows() represents the application's existing bulk-insert helper; it must not commit on its own. property_user_ids contains the property names/definitions selected by the application configuration. The processor resolves their IDs in the selected project, so IDs from another project are not reused.

from multiconn_archicad import MultiConn, is_session_ready


def ingest_project(ctx, property_user_ids) -> int:
    conn = MultiConn()
    header = conn.primary
    if header is None or not is_session_ready(header):
        raise RuntimeError("Open a project and wait for its metadata.")
    if not header.tapir_info.is_installed:
        raise RuntimeError("Install Tapir in the selected Archicad instance.")

    print(f"Project: {header.archicad_id.projectName}")
    processor = PropertyIngestor(ctx, header, property_user_ids)
    try:
        stored = processor.process()
        ctx.conn_data.commit()
    except Exception:
        ctx.conn_data.rollback()
        raise
    print(f"Rows stored: {stored}")
    return stored

This is the transaction boundary for one project. If your context manager already owns commit/rollback, keep that responsibility there instead. A failure propagates to the command-line launcher, which can log it and exit with an error status. The example requires installation of Tapir, not its latest supported release.

Processor: coordinate reading and storage

The processor receives the context and header from the entry point. It does not construct another manager or choose another project:

from multiconn_archicad import ConnHeader


class PropertyIngestor:
    def __init__(self, ctx, header: ConnHeader, property_user_ids):
        self.ctx = ctx
        self.header = header
        self.property_user_ids = list(property_user_ids)

    def process(self) -> int:
        api = self.header.unified
        properties = api.utilities.property.resolve_property_ids(self.property_user_ids)
        stored = 0
        for rows in read_property_batches(api, properties):
            self.ctx.store_rows(rows)
            stored += len(rows)
        return stored

In a larger pipeline, mapping source properties to database fields belongs here or in a separate mapping module. Keep that application logic out of connection management and the low-level Archicad reader.

Reader: work with the supplied client

The reader gets the current selection and processes it in chunks. This keeps individual property requests manageable. A chunk size of 5,000 is a workflow choice, not a required library setting:

from collections.abc import Iterator

from multiconn_archicad import UnifiedApi
from multiconn_archicad.models.tapir.types import PropertyIdArrayItem


def read_property_batches(
    api: UnifiedApi,
    properties: list[PropertyIdArrayItem],
    chunk_size: int = 5000,
) -> Iterator[list[dict[str, object]]]:
    if not properties or chunk_size < 1:
        raise ValueError("Choose properties and a positive chunk size.")

    elements = api.tapir.element.get_selected_elements()
    for start in range(0, len(elements), chunk_size):
        chunk = elements[start : start + chunk_size]
        read = api.utilities.property.get_property_values_per_element_result(chunk, properties)
        read.raise_for_non_success("Read properties for ingestion")
        complete_rows = read.aggregate_rows()
        yield [
            {"element_guid": element.elementId.guid, "values": list(row.value)}
            for element, row in zip(chunk, complete_rows.slots, strict=True)
        ]

This pipeline deliberately stops if a requested value cannot be read. If a later chunk fails, the entry point rolls back the database transaction, including uncommitted inserts from earlier chunks. It does not turn unreadable values into empty strings or silently omit elements.

Values here remain property display strings; database type conversion and field mapping belong to the application. An empty selection produces no batches and stores zero rows. The underlying workflow can also choose elements by saved layer combination; see the batch cookbook.

Example output after a successful transaction:

Project: Office building
Rows stored: 120

For several projects, keep the target loop outside this processor. Finish each project's transaction and any save/close policy before selecting the next target. See opening and switching projects.