import sys, json, collections; sys.path.insert(0,'pylib') import ezdxf F=r"D:\★Pier 자료\심수석님 검토 파일\검토_산외교P1\교각배근도(울산P1)_2016.10.28.dxf" d=ezdxf.readfile(F); m=d.modelspace() C=[] def walk(ents,depth=0): for e in ents: t=e.dxftype() if t=='CIRCLE': c=e.dxf.center; C.append((round(c.x,1),round(c.y,1),round(e.dxf.radius,1),e.dxf.layer)) elif t=='INSERT' and depth<3: try: walk(e.virtual_entities(),depth+1) except Exception: pass walk(m) json.dump(C,open('swcirc.json','w')) print(len(C),collections.Counter((c[2],c[3]) for c in C).most_common(15))