- Code\rebar_pipeline, review_pipeline, pier-program을 정션에서 실제 폴더로 전환 - Code\rhino_mcp 및 CLAUDE_rhino배경.md 추가, .mcp.json은 PYTHONPATH로 새 위치 사용 - pier-program 내부 .git 제거(이력은 backup\pier-program_20261028.bundle에 보관) - worktree 가이드 반영(CLAUDE.local.md, HANDOFF.md) - D:\Rhino-MCP 경로 참조를 새 위치로 치환 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
76 lines
3.6 KiB
Python
76 lines
3.6 KiB
Python
import ezdxf, sys, math
|
|
from collections import defaultdict
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
d = ezdxf.readfile(r'D:\★Pier 자료\심수석님 검토 파일\철근 모델랑 운곡교P1_바이브코딩\1.dxf')
|
|
ms = d.modelspace()
|
|
x0, x1, y0, y1 = [float(v) for v in sys.argv[1:5]] # region of the footing view
|
|
CX = float(sys.argv[5]) # centre x of the view
|
|
ZB = float(sys.argv[6]) # y of footing concrete bottom (drawing)
|
|
dots = []; bub = []; lines = []; txt = []; rb = []
|
|
for e in ms:
|
|
t = e.dxftype()
|
|
if t == 'CIRCLE':
|
|
c = e.dxf.center
|
|
if e.dxf.radius == 27 and x0 < c.x < x1 and y0 < c.y < y1:
|
|
dots.append((c.x, c.y))
|
|
if e.dxf.radius == 240 and x0 - 3000 < c.x < x1 + 3000 and y0 - 2500 < c.y < y1 + 3500:
|
|
bub.append((c.x, c.y))
|
|
elif t == 'LINE':
|
|
a, b = e.dxf.start, e.dxf.end
|
|
if e.dxf.layer in ('CS-DIML', 'CS-SYMB-LIN3', 'CS-SYMB') and x0 - 3500 < min(a.x, b.x) and max(a.x, b.x) < x1 + 3500 and y0 - 2500 < min(a.y, b.y) and max(a.y, b.y) < y1 + 3500:
|
|
lines.append(((a.x, a.y), (b.x, b.y)))
|
|
if e.dxf.layer == 'CS-RBAR-MAJR' and x0 < min(a.x, b.x) and max(a.x, b.x) < x1 and y0 < min(a.y, b.y) and max(a.y, b.y) < y1:
|
|
rb.append(((a.x, a.y), (b.x, b.y)))
|
|
elif t == 'TEXT':
|
|
p = e.dxf.insert
|
|
if x0 - 3500 < p.x < x1 + 3500 and y0 - 2500 < p.y < y1 + 3500:
|
|
txt.append((p.x, p.y, e.dxf.text.strip()))
|
|
n = len(lines)
|
|
par = list(range(n))
|
|
def find(i):
|
|
while par[i] != i:
|
|
par[i] = par[par[i]]; i = par[i]
|
|
return i
|
|
pts = defaultdict(list)
|
|
for i, (a, b) in enumerate(lines):
|
|
pts[(round(a[0] / 4), round(a[1] / 4))].append(i); pts[(round(b[0] / 4), round(b[1] / 4))].append(i)
|
|
for k, v in pts.items():
|
|
for j in v[1:]:
|
|
par[find(v[0])] = find(j)
|
|
comp = defaultdict(list)
|
|
for i in range(n): comp[find(i)].append(i)
|
|
def target(p):
|
|
# nearest dot within 12, else nearest rebar line within 10 (perpendicular)
|
|
best = None
|
|
for dd in dots:
|
|
dist = math.hypot(p[0] - dd[0], p[1] - dd[1])
|
|
if dist < 12 and (best is None or dist < best[0]): best = (dist, 'dot', dd[0], dd[1])
|
|
if best: return best
|
|
for (a, b) in rb:
|
|
if abs(a[1] - b[1]) < 0.6: # horizontal bar line
|
|
if min(a[0], b[0]) - 6 <= p[0] <= max(a[0], b[0]) + 6 and abs(p[1] - a[1]) < 8:
|
|
return (abs(p[1] - a[1]), 'hline', p[0], a[1])
|
|
if abs(a[0] - b[0]) < 0.6: # vertical bar line
|
|
if min(a[1], b[1]) - 6 <= p[1] <= max(a[1], b[1]) + 6 and abs(p[0] - a[0]) < 8:
|
|
return (abs(p[0] - a[0]), 'vline', a[0], p[1])
|
|
return None
|
|
for (bx, by) in sorted(bub):
|
|
lab = [t for t in txt if abs(t[0] - bx) < 260 and abs(t[1] - by) < 260 and t[2].startswith('B') and t[2][1:].isdigit()]
|
|
if not lab: continue
|
|
name = lab[0][2]
|
|
ul = by - 252
|
|
cand = [i for i, (a, b) in enumerate(lines) if abs(a[1] - ul) < 4 and abs(b[1] - ul) < 4 and min(a[0], b[0]) < bx + 300 and max(a[0], b[0]) > bx - 300]
|
|
hits = []
|
|
seen = set()
|
|
for i in cand:
|
|
for j in comp[find(i)]:
|
|
for p in lines[j]:
|
|
tg = target(p)
|
|
if tg and (round(tg[2]), round(tg[3]), tg[1]) not in seen:
|
|
seen.add((round(tg[2]), round(tg[3]), tg[1]))
|
|
hits.append(tg)
|
|
out = []
|
|
for dist, kind, x, y in hits:
|
|
out.append('%s z=%.1f(+%.1f from bottom) xoff=%+.0f' % (kind, 26208 + (y - ZB), y - ZB, x - CX))
|
|
print(name, '(bubble %.0f,%.0f)' % (bx, by), '->', out if out else 'no target found (underline lines %d)' % len(cand))
|