"""Okseong P1 footing rebar reading (G3: B1~B12, UM) -> 판독/g3_values.json. Sheet 구조도(1): front CL x 573551.6, side CL x 592540.9, z = drawing y - 309179.8 (footing EL 12.175~14.375). Sheet 구조도(3) footing plan: centre (654657.6, 333805.6); B9 symbols = EREC vertical lines 400 / 438 long (lower half only drawn). Chains: front '100 | 2@100 | 72@125=9.000 | 2@100 | 100' (Y bars, 77), side '100 | 2@163 | 70@125=8.750 | 2@163 | 100' (X bars, 75), mid '18@500' (front) / '538 | 16@500 | 538' (side). """ import json from collections import Counter from pathlib import Path from dxftools import entities ZO = -309179.8 def dots(cx, z): return sorted(round(e.dxf.insert.x - cx, 1) for e in entities("D1", cx - 5000, z - ZO - 5, cx + 5000, z - ZO + 5, "CS-RBAR") if e.dxftype() == "INSERT") F, S = 573551.6, 592540.9 out = {"y_bars_bottom": {"z": 12325.0, "x": dots(F, 12325.0)}, "y_bars_top": {"z": 14275.0, "x": dots(F, 14275.0)}, "x_bars_bottom": {"z": 12347.5, "y": dots(S, 12347.5)}, "x_bars_top": {"z": 14252.5, "y": dots(S, 14252.5)}, "mid_y_bars": {"13825": [x for x in dots(F, 13825.0) if abs(x) < 4700], "12825": [x for x in dots(F, 12825.0) if abs(x) < 4700]}, "mid_x_bars": {"13825": [y for y in dots(S, 13825.0) if abs(y) < 4700 and y % 1000 == 0], "12825": [y for y in dots(S, 12825.0) if abs(y) < 4700]}, "b10_levels": [z for z in (12575.0, 12825.0, 13325.0, 13825.0, 14075.0) if -4722.5 in dots(F, z)], "b10_corner": 4722.5} cx, cy = 654657.6, 333805.6 v = [e for e in entities("D1", 646500, 327500, 660500, 340500, "CS-RBAR-EREC") if e.dxftype() == "LINE" and abs(e.dxf.start.x - e.dxf.end.x) < 0.5 and 390 < e.dxf.start.distance(e.dxf.end) < 450] half = sorted((round(e.dxf.start.x - cx, 1), round((e.dxf.start.y + e.dxf.end.y) / 2 - cy, 2)) for e in v) out["b9_lower_half_drawn"] = {"count": len(half), "points": half, "x_columns": sorted(Counter(p[0] for p in half)), "rows": sorted(Counter(p[1] for p in half))} out["counts"] = {k: len(v_["x"] if "x" in v_ else v_["y"]) for k, v_ in out.items() if k.endswith(("bottom", "top"))} p = Path(__file__).resolve().parent / "판독" / "g3_values.json" p.write_text(json.dumps(out, ensure_ascii=False, indent=1), encoding="utf-8") print(out["counts"], {k: {z: len(v_) for z, v_ in out[k].items()} for k in ("mid_y_bars", "mid_x_bars")}, out["b10_levels"], out["b9_lower_half_drawn"]["count"], out["b9_lower_half_drawn"]["rows"])