engineering/arch/draw.py is the only module of the track that touches a backend. It draws through draw_prims(role_layer=ARCH_ROLE_LAYER) and the generic contract members, so it runs on both engines as written, and it writes the plan onto the drawing: each element's ACADMCP_ARCH record on one of its own entities (a wall's first face line, a door's leaf, a window's frame, a stair's first riser) and, beside it under ACADMCP_ARCH_H, the handles that element owns. read_plan reads the records back and never modifies the drawing. arch_wall computes the whole network before and after the new walls and redraws only the drawn walls whose outline changes - erasing exactly the entities they own - and says which under redrawn. arch_opening hosts a door or a window in a drawn wall found by id and redraws that wall cut; its tag defaults to the next D1/W1 (K1/P1 in Turkish). A new wall that would leave a drawn opening uncuttable, and an opening that runs into a junction, are refused before anything is erased. arch_stair reports the Blondel value; it does not enforce it. exterior_chains gives each side up to three rows, nearest first: every jamb in that facade, both faces of every wall meeting it, and the overall - from the wall engine's own faces. A row that would only restate a farther one is not emitted (ISO 129-1: each measurement once). The 10 mm / 8 mm row spacing is a declared drafting default times the plot scale, not a standard value. The arch tag is ranked after mech so the four tools file under a new architecture group; alias records carry WALLADD/MLINE, DOORADD/WINDOWADD and STAIRADD with English and Turkish shop words. Inventory regenerated; README snapshot 233 tools (228 advertised) in 26 groups; registry snapshot architecture: 4. No new ActiveX member is called. Measured on AutoCAD 2026 in a scratch document through ComBackend: shell + teed partition, D1 + W1, a straight 17-riser stair and the bottom chains gave the same 20 wall LINEs (identical endpoints), 9 poche HATCHes, 1+1 door, 4 window lines, 11 dimensions and a read_plan round trip as the headless engine. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
108 lines
4.4 KiB
Python
108 lines
4.4 KiB
Python
"""Exterior dimension chains: three rows per side, from the wall engine's own faces.
|
|
|
|
The plan: a closed 8200 x 6200 axis rectangle of 200 mm walls (outer faces
|
|
-100..8300 x -100..6300), a 100 mm partition on x = 4100 teed into the bottom
|
|
and top walls (faces x = 4050 / 4150), a 1200 window at 1500 and a 1000 door
|
|
at 5500 in the bottom wall. Every point below is hand-computed from those
|
|
numbers; at 1:50 the rows sit 500, 900 and 1300 mm outside the building.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from engineering.arch.dimension import (
|
|
FIRST_OFFSET_PAPER_MM,
|
|
ROWS,
|
|
SIDES,
|
|
STEP_PAPER_MM,
|
|
exterior_chains,
|
|
)
|
|
from engineering.arch.model import Opening, Wall
|
|
from engineering.mech.primitives import DimIntent
|
|
|
|
SHELL = Wall(
|
|
id="shell",
|
|
axis=((0.0, 0.0), (8200.0, 0.0), (8200.0, 6200.0), (0.0, 6200.0)),
|
|
thickness=200.0,
|
|
closed=True,
|
|
)
|
|
PARTITION = Wall(id="p", axis=((4100.0, 0.0), (4100.0, 6200.0)), thickness=100.0)
|
|
WINDOW = Opening(id="w1", wall="shell", kind="window", offset=1500.0, width=1200.0)
|
|
DOOR = Opening(id="d1", wall="shell", kind="door", offset=5500.0, width=1000.0)
|
|
|
|
|
|
def row(intents, feature) -> list[tuple]:
|
|
out = []
|
|
for intent in intents:
|
|
if intent.feature == feature:
|
|
out.append(
|
|
(
|
|
tuple(round(v, 9) + 0.0 for v in intent.p1),
|
|
tuple(round(v, 9) + 0.0 for v in intent.p2),
|
|
tuple(round(v, 9) + 0.0 for v in intent.text_at),
|
|
)
|
|
)
|
|
return out
|
|
|
|
|
|
def test_the_rows_and_the_offsets_are_declared():
|
|
assert SIDES == ("bottom", "top", "left", "right")
|
|
assert ROWS == ("openings", "walls", "overall")
|
|
assert (FIRST_OFFSET_PAPER_MM, STEP_PAPER_MM) == (10.0, 8.0)
|
|
|
|
|
|
def test_the_bottom_side_carries_openings_walls_and_overall():
|
|
intents = exterior_chains([SHELL, PARTITION], [WINDOW, DOOR], sides=("bottom",), scale=50)
|
|
assert all(isinstance(i, DimIntent) and i.kind == "linear" for i in intents)
|
|
assert row(intents, "bottom:openings") == [
|
|
((-100.0, -100.0), (1500.0, -100.0), (700.0, -600.0)),
|
|
((1500.0, -100.0), (2700.0, -100.0), (2100.0, -600.0)),
|
|
((2700.0, -100.0), (5500.0, -100.0), (4100.0, -600.0)),
|
|
((5500.0, -100.0), (6500.0, -100.0), (6000.0, -600.0)),
|
|
((6500.0, -100.0), (8300.0, -100.0), (7400.0, -600.0)),
|
|
]
|
|
assert row(intents, "bottom:walls") == [
|
|
((-100.0, -100.0), (100.0, -100.0), (0.0, -1000.0)),
|
|
((100.0, -100.0), (4050.0, -100.0), (2075.0, -1000.0)),
|
|
((4050.0, -100.0), (4150.0, -100.0), (4100.0, -1000.0)),
|
|
((4150.0, -100.0), (8100.0, -100.0), (6125.0, -1000.0)),
|
|
((8100.0, -100.0), (8300.0, -100.0), (8200.0, -1000.0)),
|
|
]
|
|
assert row(intents, "bottom:overall") == [
|
|
((-100.0, -100.0), (8300.0, -100.0), (4100.0, -1400.0)),
|
|
]
|
|
assert len(intents) == 11
|
|
|
|
|
|
def test_a_row_that_repeats_a_farther_one_is_not_emitted():
|
|
intents = exterior_chains([SHELL, PARTITION], [WINDOW, DOOR], sides=("left",), scale=50)
|
|
# no opening in the left wall: that row would only restate the overall one
|
|
assert row(intents, "left:openings") == []
|
|
assert row(intents, "left:walls") == [
|
|
((-100.0, -100.0), (-100.0, 100.0), (-1000.0, 0.0)),
|
|
((-100.0, 100.0), (-100.0, 6100.0), (-1000.0, 3100.0)),
|
|
((-100.0, 6100.0), (-100.0, 6300.0), (-1000.0, 6200.0)),
|
|
]
|
|
assert row(intents, "left:overall") == [((-100.0, -100.0), (-100.0, 6300.0), (-1400.0, 3100.0))]
|
|
|
|
|
|
def test_explicit_offsets_override_the_plot_scale_defaults():
|
|
intents = exterior_chains(
|
|
[SHELL], [], sides=("top",), first_offset=300.0, step=250.0, scale=100
|
|
)
|
|
# the top: the extremes only, so the walls row is the corner walls' faces
|
|
assert row(intents, "top:overall") == [((-100.0, 6300.0), (8300.0, 6300.0), (4100.0, 7100.0))]
|
|
assert {i.text_at[1] for i in intents if i.feature == "top:walls"} == {6850.0}
|
|
|
|
|
|
def test_bad_sides_and_scales_are_refused_by_name():
|
|
with pytest.raises(ValueError, match=r"sides\[0\]: 'north'"):
|
|
exterior_chains([SHELL], [], sides=("north",))
|
|
with pytest.raises(ValueError, match="named twice"):
|
|
exterior_chains([SHELL], [], sides=("left", "left"))
|
|
with pytest.raises(ValueError, match="scale"):
|
|
exterior_chains([SHELL], [], scale=0)
|
|
with pytest.raises(ValueError, match="sides"):
|
|
exterior_chains([SHELL], [], sides="bottom")
|