import sys, re, json, collections sys.path.insert(0, 'pylib') import ezdxf F = r"D:\★Pier 자료\심수석님 검토 파일\Ramp-A교P1\Ramp-A교 P1 교각(3).dxf" d = ezdxf.readfile(F) m = d.modelspace() FONT = re.compile(r'\f[^;]*;') texts = []; tags = [] names = collections.Counter() for e in m: t = e.dxftype() if t == 'TEXT': texts.append((e.dxf.insert.x, e.dxf.insert.y, e.dxf.text, e.dxf.layer)) elif t == 'MTEXT': s = FONT.sub('', e.text).replace('{', '').replace('}', '').replace('\P', ' / ') texts.append((e.dxf.insert.x, e.dxf.insert.y, s, e.dxf.layer)) elif t == 'INSERT': at = [(a.dxf.tag, a.dxf.text) for a in e.attribs] if at: tags.append((e.dxf.insert.x, e.dxf.insert.y, e.dxf.name, at)) names[e.dxf.name] += 1 print(len(texts), len(tags), names.most_common(5)) Ls = [t for t in texts if re.match(r'\s*L\s*=\s*[\d.,]+\s*$', t[2])] print(len(Ls)) for t in sorted(Ls, key=lambda a: (round(a[0] / 3000), -a[1]))[:60]: print(round(t[0]), round(t[1]), t[2]) json.dump({'texts': texts, 'tags': tags}, open('ra_shape_raw.json', 'w', encoding='utf-8'), ensure_ascii=False)