Skip to content

AskReferencePositions (Auxiliary)

Requires an AskFeatures or AskMetaData request

This is an auxiliary request that must be accompanied by an AskFeatures or AskMetaData request. It returns the positions of the elements those asks extracted in the same request. Asked on its own, there is nothing to position and you receive no reference positions.

Description

AskReferencePositions returns where each extracted element sits on the sheet. Every dimension, thread, bore, title-block entry and other element in an AskFeatures or AskMetaData response carries a reference_id; this ask returns a ReferencePosition for each of them: the same reference_id together with a Polygon outlining the element.

When to use

  • Traceability and review UIs: highlight a dimension on the sheet when a user selects it in a table, or the other way round.
  • Checking a result against the drawing: show a reviewer exactly which callout a value was read from.

Join the positions to the other responses by reference_id (together with the page, see Reference ID). Draw them on the image returned by AskSheetImages rather than on your original upload: Werk24 corrects the page rotation, and the coordinates refer to the corrected sheet.

How to read the response:

  • You receive one response per page, carrying the positions of that page's elements.
  • coordinate_space says which space the coordinates are in. Positions are given in PIXEL_SPACE, pixel coordinates on the sheet.
  • A polygon can have as few as two points: a dimension, for example, is placed as the line it sits on.
  • An element without a location on the sheet has a polygon that is null or has no coordinates. Treat both as "not placed".

Example Usage

1
2
3
4
5
6
7
from werk24 import AskFeatures, AskReferencePositions, AskType, read_example_drawing

results = read_example_drawing([AskFeatures(), AskReferencePositions()])

for message in results[AskType.REFERENCE_POSITIONS]:
    for position in message.payload_dict.reference_positions:
        print(message.page_number, position.reference_id, position.polygon)

ResponseReferencePositions

Bases: Response

A class that represents an Response to a request for the position of a component in the drawing.

PARAMETER DESCRIPTION
ask_version

TYPE: Literal['v2'] DEFAULT: 'v2'

ask_type

TYPE: Literal[<AskType.REFERENCE_POSITIONS: 'REFERENCE_POSITIONS'>] DEFAULT: <AskType.REFERENCE_POSITIONS: 'REFERENCE_POSITIONS'>

reference_positions

The positions of the component in the drawing.

TYPE: list[ReferencePosition]

Source code in werk24/models/v2/responses.py
class ResponseReferencePositions(Response):
    """
    A class that represents an Response to a request for the position of a component in the drawing.
    """

    ask_type: Literal[AskType.REFERENCE_POSITIONS] = AskType.REFERENCE_POSITIONS

    reference_positions: list[ReferencePosition] = Field(
        ..., description="The positions of the component in the drawing."
    )

Example Response

{
    "ask_version": "v2",
    "ask_type": "REFERENCE_POSITIONS",
    "reference_positions": [
        {
            "reference_id": 0,
            "polygon": {
                "coordinate_space": "PIXEL_SPACE",
                "coordinates": [[412, 236], [598, 236]]
            }
        },
        {
            "reference_id": 1,
            "polygon": {
                "coordinate_space": "PIXEL_SPACE",
                "coordinates": [[1510, 1180], [1790, 1180], [1790, 1224], [1510, 1224]]
            }
        }
    ]
}

Here reference_id 0 is a dimension, placed as a line, and reference_id 1 is a title-block entry, placed as a rectangle.