"""Ramp-A P1 shaft cage reading (G3: P1-1, P1-2, P2-1, P3-1, P3-2, PLATE) from D4 -> 판독/g3_values.json. D4 elevation is schematic (upper D2,500 part drawn 12,700 long, rock line 3,900 above the bottom vs D1 7,500), so levels come from the 구조물 치수표 (H 12,700; H1 17@600, H2 6@300, H3 34@300, H4 13@150, H5 340, H6 340) and the chain texts ('260' / '110' at the top, '100' at the bottom). Sections G-G / J-J give radii and bar angles. """ import json import math from collections import Counter from pathlib import Path from dxftools import entities out = {} for name, (x0, y0, x1, y1) in {"G-G": (90000, -697000, 96000, -688000), "J-J": (98000, -706000, 104500, -697000)}.items(): big = [e for e in entities("D4", x0, y0, x1, y1) if e.dxftype() == "CIRCLE" and e.dxf.radius > 1000] c = big[0].dxf.center radii = sorted({round(e.dxf.radius, 1) for e in big if e.dxf.center.distance(c) < 1}) ins = [e for e in entities("D4", x0, y0, x1, y1) if e.dxftype() == "INSERT"] rr = Counter(round(math.hypot(e.dxf.insert.x - c.x, e.dxf.insert.y - c.y), 1) for e in ins) r0 = rr.most_common(1)[0][0] a = sorted(round(math.degrees(math.atan2(e.dxf.insert.y - c.y, e.dxf.insert.x - c.x)) % 360, 3) for e in ins if abs(math.hypot(e.dxf.insert.x - c.x, e.dxf.insert.y - c.y) - r0) < 1) lines = [round(e.dxf.start.distance(e.dxf.end), 1) for e in entities("D4", x0, y0, x1, y1, "CS-RBAR") if e.dxftype() == "LINE" and e.dxf.start.distance(e.dxf.end) > 1500] out[name] = {"concrete_and_hoop_radii": radii, "bar_symbol_radius": r0, "bar_count": len(a), "first_deg": a[0], "step_deg": round((a[-1] - a[0]) / (len(a) - 1), 4) if name == "J-J" else None, "tie_lines": lines} H0 = 45452.0 # shaft top (D1) hoops = [H0 - 110 - 150 * k for k in range(14)] hoops += [hoops[-1] - 300 * k for k in range(1, 35)] ties = [H0 - 260 - 300 * k for k in range(7)] ties += [ties[-1] - 600 * k for k in range(1, 18)] out["hoop_levels_from_table"] = {"count": len(hoops), "top": hoops[0], "bottom": hoops[-1], "rule": "shaft top -110, 13@150, 34@300 (+H6 340 +100 = shaft bottom)"} out["tie_levels_from_table"] = {"count": len(ties), "top": ties[0], "bottom": ties[-1], "rule": "shaft top -260, 6@300, 17@600 (+H5 340 +100)"} out["chain_check"] = {"hoops": 110 + 1950 + 10200 + 340 + 100, "ties": 260 + 1800 + 10200 + 340 + 100, "H": 12700} out["main_span"] = {"top": hoops[0], "bottom": hoops[-1], "length": hoops[0] - hoops[-1], "P1-1 + P1-2": 8750 + 3400} p = Path(__file__).resolve().parent / "판독" / "g3_values.json" p.write_text(json.dumps(out, ensure_ascii=False, indent=1), encoding="utf-8") print(json.dumps(out, ensure_ascii=False))