Skip to content

Inspect batch results without losing element references

A property read can succeed for some elements and fail for others. A batch result keeps each value or error in its original position, so you can report which element and property need attention.

If you use Grasshopper, think of a property grid as a tree with one branch per element and one item per requested property. A failed item keeps its position, so the next element's data does not slide into its place. The grid uses row and column numbers rather than Grasshopper paths; there is no automatic data matching.

Use a utility's _result method when you need these details. It returns a result container rather than stopping at the first returned item error. Connection, request, and setup failures can still raise exceptions.

Read wall IDs and layer names

This read-only script needs an open project, Tapir, and uv as described in the quick start. It reads walls from the current plan and reports property values or errors against each wall's GUID.

Save it as read_wall_properties.py. Run it with uv run read_wall_properties.py in your Python project. To distribute it through the palette, follow the Tapir palette guide.

from multiconn_archicad import UnifiedApi
from multiconn_archicad.models.official.types import BuiltInPropertyUserId, ElementType
from multiconn_archicad.utilities import SlotState

api = UnifiedApi()
walls = api.official.element_listing.get_elements_by_type(ElementType.WALL)
property_names = ["Element ID", "Layer name"]
properties = api.utilities.property.resolve_property_ids([
    BuiltInPropertyUserId(nonLocalizedName="General_ElementID"),
    BuiltInPropertyUserId(nonLocalizedName="ModelView_LayerName"),
])

if not walls:
    print("No walls found in the current plan.")
else:
    result = api.utilities.property.get_property_values_per_element_result(
        walls, properties
    )
    print(f"Values read: {result.count(SlotState.SUCCESS)}")
    print(f"Errors: {result.count(SlotState.ERROR)}")

    for (row, column), value in result.iter_successes():
        guid = walls[row].elementId.guid
        print(f"Wall {row + 1} ({guid}) | {property_names[column]}: {value}")

    for (row, column), error in result.iter_errors():
        guid = walls[row].elementId.guid
        print(f"Wall {row + 1} ({guid}) | {property_names[column]}: {error.message}")

Example output for two walls, with one failed property read. GUIDs are shortened for readability; actual IDs, values, and error messages depend on the project:

Values read: 3
Errors: 1
Wall 1 (a1b2...) | Element ID: W-01
Wall 1 (a1b2...) | Layer name: A-WALL
Wall 2 (c3d4...) | Element ID: W-02
Wall 2 (c3d4...) | Layer name: Property unavailable

For 12 walls and two properties, the result has 12 rows and two columns. result.count() counts property cells, so it returns 24. Coordinates start at zero: (3, 1) means the fourth wall and its layer name.

An error keeps its cell. Do not zip result.successes with the original walls: that list contains only successful values and no longer preserves the grid. Use the coordinates from iter_successes() and iter_errors() instead.

The property utility returns strings. Numeric reads use display strings by default. Pass use_si_units=True for precise numeric strings in SI units, with angles in degrees; this option requires Tapir 2.0.0 or newer.

Understand the four cell states

Each cell is a BatchSlot. A BatchGrid arranges cells in rows and columns; a BatchResult holds one cell per input item.

State Meaning Example
SUCCESS A value is available. A wall's layer name was read.
ERROR This operation returned a failure. A property is unavailable or undefined.
UPSTREAM_FAILED An earlier failure prevented this step. A calculation could not run because a dimension read failed.
FILTERED Application logic intentionally omitted this work. The wall is outside the chosen work package.

Only successful cells have a .value; only error cells have an .error. Filtered and upstream-failed cells do not contain replacement values.

Count complete elements

Continue the script's else block when all requested properties are required:

complete_rows = result.aggregate_rows()
for row, values in complete_rows.iter_successes():
    element_id, layer_name = values
    print(f"Ready: {walls[row].elementId.guid} | {element_id} | {layer_name}")

aggregate_rows() produces one result per wall. A successful row contains all its values. A row containing an error becomes an error result, so it will not appear in this loop. This is useful before a calculation that needs every input. In Grasshopper terms, this checks whether a branch has all the values needed for the next operation. It does not flatten the original grid.

Report a finished or interrupted workflow

Use PopulationResults when you need to connect results from several steps back to the original elements. Here, population means the ordered list you started with. Continue the same else block:

from multiconn_archicad.utilities import BatchStatus, PopulationResults

population = PopulationResults(walls)
population.record("Read wall properties", result)
report = population.snapshot(completed=True)

print(f"Walls read successfully: {report.count(BatchStatus.SUCCEEDED)}")
print(f"Walls with errors: {report.count(BatchStatus.FAILED)}")
for outcome, failure in report.iter_failures():
    print(f"Wall {outcome.index + 1}: {failure.error.message}")

For the two-wall example above, the report output would be:

Walls read successfully: 1
Walls with errors: 1
Wall 2: Property unavailable

completed=True means your intended workflow reached its end. It does not mean every element succeeded. Here, a wall with a failed property cell remains FAILED, even though the read step finished.

If the workflow stops early, take snapshot(completed=False). Otherwise-clean items become INCOMPLETE; recorded direct failures stay FAILED. The collector records results; it does not run commands, catch exceptions, or roll back edits. Your application decides whether to continue and how to report an interruption.

Choose when to stop

  • Inspect iter_errors() to report failures and continue with readable data.
  • Call raise_for_errors() to stop on direct errors. It allows filtered and upstream-failed cells.
  • Call raise_for_non_success() when every cell must succeed. It also rejects filtered and upstream-failed cells.

Both raise methods accept an empty result. is_all(SlotState.SUCCESS) returns false for an empty result. Decide separately whether "nothing to process" is acceptable for your task.

For copying properties, projecting successful cells into a later step, and matching different element lists, see the batch pipeline cookbook.