import sys; sys.path.insert(0,".") import json, collections, io from swdots import dots B=json.load(open('swpos.json',encoding='utf-8')) OFF=328016.3 o=io.open('swfoot2.txt','w',encoding='utf-8') foot=['B1','B2','B3','B4','B5','B6','B7','B8','B9','B10'] for nm,(x0,x1,cx,ax,perp) in (('정면도',(6700,14250,10473.9,0,1)),('측면도',(20850,28400,24604.3,1,0))): # 도면 점 (원 지름 22.5 = 안쪽 점) D=[(d[0]-cx,d[1]) for d in dots(x0,x1,-285300,-282700) if d[2]==22.5] # 모델: 보는 방향(perp 축)으로 길게 뻗은 철근 — 끝이 보이는 점 M=[] for m in foot: for b in B[m]: bb=b['bb']; ext=[bb[3]-bb[0],bb[4]-bb[1],bb[5]-bb[2]] if ext[perp]>1000 and ext[ax]<60 and ext[2]<60: M.append(((bb[ax]+bb[ax+3])/2,(bb[2]+bb[5])/2-OFF,m)) o.write(u'== %s: 도면 점 %d, 모델 \"끝이 보이는\" 철근 %d\n'%(nm,len(D),len(M))) # 도면점 -> 모델 unmatchedD=[]; used=set() for (x,y) in D: best=None for i,(mx,mz,m) in enumerate(M): d=max(abs(mx-x),abs(mz-y)) if best is None or d