Check project metadata and readiness¶
A discovered port is not enough to start every task. A script may need a project name, a supported Tapir version, or saved project identity. Check the requirement you actually need before reading the corresponding metadata or running commands.
| Check | What it establishes |
|---|---|
is_session_ready(header) |
A ready session with current product/project metadata and completed Tapir polling. |
is_tapir_session_ready(header) |
A ready session with an installed Tapir version meeting the library's supported version. |
is_tapir_session_ready(header, min_version="2.0.0") |
A ready session meeting that task's explicit Tapir minimum. |
has_project_identity(header) |
Enough saved project and executable identity for serialization/opening workflows. |
The session checks support untitled projects. A project can be ready for commands
without having the saved identity required for reopening it later.
is_session_ready alone does not require Tapir to be installed or supported.
For a Tapir task, check installation after session readiness. Use a minimum
version only for commands that need it; the default supported-version guard is
an optional stricter policy, not a requirement for every script.
Check at the script entry point¶
from multiconn_archicad import ConnHeader, is_session_ready
from multiconn_archicad.models.official.types import ElementType
def run_script(header: ConnHeader) -> int:
if not is_session_ready(header):
raise RuntimeError("Wait for a ready Archicad project.")
print(f"Project: {header.archicad_id.projectName}")
print(f"Archicad: {header.product_info.version}")
walls = header.unified.official.element_listing.get_elements_by_type(ElementType.WALL)
return len(walls)
These helpers are also Python type guards: they tell a type checker that the following code can use the more specific metadata fields.
Metadata can be pending or fail¶
Header fields include archicad_id, product_info, tapir_info, and
archicad_location. Before a successful check, a metadata field can contain an
API error or pending placeholder instead of the expected record.
latest_metadata is the current fetch result; it is None while a fetch is
pending or canceled. Do not treat a historical project name or a port number as
proof that the current project is ready.
In normal script mode, access can wait for fetching. In UI mode it returns pending state so the interface can remain responsive. See lifecycle and events.
A readiness check describes that moment. It does not lock the project or stop an instance from closing. Keep project switching separate from ongoing work and handle request failures at the application boundary.