Detecting Doors from Swing Arc Blocks

An addition to Wall & Door Detection Algorithms. Measuring the gap in a wall finds most doors; reading the swing symbol drawn beside it finds the rest and recovers two facts the gap cannot supply.

What the Symbol Carries

A door swing block and what it tells you that a gap does not A wall run with a gap in it. A teal quarter-circle arc is drawn from a rose hinge point at one edge of the gap, together with the door leaf as a radius line. The arc's radius gives the door width — three metres here — and its direction gives the swing side. The dashed amber line marks the opening the arc implies, spanning the gap in the wall. A hinge, a radius and a sweep — three numbers, two extra facts leaf + arc: hinge at 11,4, width 3.0 m hinge the arc gives width and swing direction; the gap alone gives neither swing arc hinge point the opening it implies

The arc carries two facts the gap does not. Its radius is the leaf width even when the wall gap is wider, and its direction says which way the door opens — which an accessibility profile needs.

A door in an architectural drawing is conventionally a leaf line and a quarter-circle arc from its hinge. Both are geometry an extractor can read, and together they carry more than the wall gap does:

  • Leaf width is the arc’s radius, which is the door’s actual clear width. The wall gap may be wider — a 0.9 m door in a 1.1 m structural opening is common — and the clear width is what an accessibility profile needs.
  • Swing direction is the arc’s sweep and centre. Nothing in the wall geometry says which way a door opens, and there is no other source for it.
  • Hinge side, which matters for the same reason.
What adding swing-arc detection recovers Grouped bars over three detection strategies on one eight-level building. Using gap width alone finds 214 doors and knows the swing direction of none of them. Adding swing-arc detection finds 231 doors — seventeen more, in openings too wide for the gap rule — and recovers swing direction for 198. Adding door-block detection does not increase the count further on this building but confirms the widths. Seventeen more doors, and 198 swing directions 0 100 200 1 2 3 1 gap only 2 gap + arcs 3 gap + arcs + blocks doors on one 8-level building doors found (gap width only) doors found (gap + swing arc) with swing direction known

The middle bar is the real gain. Swing direction is not recoverable from geometry any other way, and an accessibility profile that needs to know which side a door opens has no other source.

Signatures and Their Lookalikes

Door signatures in CAD drawings and what each yields A table of five drawing signatures. An ARC entity gives a centre, radius and sweep angles, yielding door width and swing side, but 90-degree arcs are also used as fillets. An INSERT of a door block gives a block name and insertion point with width available from the block definition, though exploded copies also occur. A line at 45 degrees inside a gap is a schematic leaf giving swing side only, and the same convention is used for windows. Two arcs sharing a centre are double doors and should be counted once with their widths combined. An arc with no corresponding wall gap is a fitting rather than a door and must be rejected. Five signatures, five lookalikes, one shared filter Drawing signature Signature Gives you Watch for ARC entity centre, radius, angles width + side △ 90° arcs used as fillets INSERT of a door block block name, insert point ● width from the block exploded copies LINE at 45° in a gap a schematic leaf side only △ also used for windows Two arcs, shared centre double doors ● combined width count once Arc with no gap a fitting, not a door nothing △ reject on gap absence An arc without a corresponding wall gap is not a door — the gap is the necessary condition.

Every signature has a lookalike. Requiring a wall gap at the arc's chord removes almost all of them, which is why detection uses the arc to describe a door rather than to find one.

The critical rule is that the arc describes a door, it does not find one. Arcs appear everywhere in architectural drawings — as fillets on corners, as furniture, as pipe bends — and an extractor that treats every 90° arc as a door produces dozens of phantom openings per floor.

Requiring a corresponding gap in a wall run at the arc’s chord removes essentially all of them. The gap remains the necessary condition; the arc supplies the detail.

Minimal Working Example

import logging
import math

from shapely.geometry import LineString, Point

logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
logger = logging.getLogger(__name__)


def door_from_arc(arc: dict, gaps: list[dict], *, tol: float = 0.25) -> dict | None:
    """Match a swing arc to a wall gap and return the door it describes."""
    for key in ("cx", "cy", "r", "start_deg", "end_deg"):
        if key not in arc:
            raise KeyError(f"arc is missing {key!r}")

    sweep = abs(arc["end_deg"] - arc["start_deg"]) % 360.0
    if not 60.0 <= sweep <= 130.0:
        return None                                # a door swing is a quarter turn
    if not 0.6 <= arc["r"] <= 1.6:
        return None                                # outside any real door leaf width

    hinge = Point(arc["cx"], arc["cy"])
    end = Point(arc["cx"] + arc["r"] * math.cos(math.radians(arc["end_deg"])),
                arc["cy"] + arc["r"] * math.sin(math.radians(arc["end_deg"])))
    chord = LineString([hinge, end])

    for gap in gaps:
        centre = Point(gap["x"], gap["y"])
        if chord.distance(centre) > tol:
            continue
        return {"x": gap["x"], "y": gap["y"],
                "clear_width_m": round(arc["r"], 3),
                "opening_width_m": gap["width"],
                "swing_deg": round(arc["start_deg"], 1),
                "hinge": (arc["cx"], arc["cy"]),
                "source": "swing_arc"}

    logger.info("arc at (%.2f, %.2f) r=%.2f has no matching wall gap; ignored",
                arc["cx"], arc["cy"], arc["r"])
    return None

The two filters before the geometric match — a sweep between 60° and 130°, and a radius between 0.6 m and 1.6 m — remove the overwhelming majority of non-door arcs before any spatial work runs, which matters because the spatial match is the expensive part.

Common Errors & Fixes

Phantom doors on every corner. Fillet arcs are being accepted. Both the radius filter and the gap requirement should exclude them; a fillet has a radius of a few centimetres and no wall gap.

Double doors counted twice. Two arcs share a hinge line and both match the same gap. Merge openings closer than about 0.4 m, summing their clear widths, exactly as node placement does downstream — doing it here as well means the merged width is available to detection.

Clear width is larger than the opening. The arc belongs to a different door. Tighten the chord tolerance, and prefer the gap when the two disagree by more than a few centimetres.

Swing direction is recorded and never used. Worth checking, because the field is only useful if something consumes it. Turn-by-turn generation should say “pull the door” where the swing faces the traveller, and an accessibility profile with a door-operating-force rule needs the hinge side to reason about approach clearance. A field that is populated and ignored is a maintenance cost with no benefit; either wire it up or stop recording it.

No arcs anywhere, but doors exist. The drawing uses door blocks rather than exploded arcs. Look for INSERT entities whose block name matches a door pattern and read the width from the block definition — the same information, in a different form, as the ezdxf entity reference describes.

Integration Point

Swing detection runs inside wall and door detection, after gaps have been measured and before openings are emitted. Its output enriches the opening record rather than replacing it: the gap supplies the position and the structural opening width, the arc supplies clear width and swing.

Those extra fields matter downstream. Clear width is what accessible routing profiles tests against a minimum; swing direction is what a turn-by-turn generator uses to say “pull the door towards you”, and what IMDF publication carries on an opening feature.

Frequently Asked Questions

Is the swing arc reliable enough to trust for clear width?

For the leaf itself, yes; for the clear opening a wheelchair actually passes through, nearly. The arc radius is the door leaf’s width as drawn, which is what the manufacturer supplies and what the architect specified. The genuine clear width is slightly less, because an open leaf at 90 degrees still intrudes by its thickness and the frame takes a few millimetres — typically 30 to 50 mm in total. Where the distinction matters, subtract a fixed allowance rather than trying to model it; where it does not, the arc radius is a much better estimate than the structural gap.

What about sliding and revolving doors?

Both need their own signatures and both matter for accessibility. A sliding door is drawn as a leaf parallel to the wall with no arc, so the gap rule finds it and the swing rule does not — which is correct, since it has no swing. A revolving door is drawn as a circle with radial leaves and is usually accompanied by a separate pass door; detecting the circle and treating it as impassable for step-free and service profiles, while routing those profiles through the pass door, is the behaviour every accessibility profile expects.

Should a door without a swing arc be treated differently?

Only in what is recorded, not in whether it is a door. The gap is the evidence that an opening exists; the arc is extra detail. A door found by gap alone should be emitted with its structural opening width and a null swing direction, so consumers can tell the difference between “opens outward” and “we do not know”. Filling in a default swing would be worse than leaving it null, because a turn-by-turn instruction that tells someone to push a door that pulls is actively unhelpful.

This page is a companion to Wall & Door Detection Algorithms, part of the Automated Floor Plan Parsing & Vectorization section.