import sys, json, collections, math, io sys.path.insert(0,'pylib') import rhino3dm m3=rhino3dm.File3dm.Read(r"D:\★Pier 자료\심수석님 검토 파일\검토_옥성교P1\옥성교P1_G5.3dm") o=io.open('ok_rerun3.txt','w',encoding='utf-8') want=('P1','P2','P3','P4','P5','B9','C8','C10','C12','C20','C18') S=collections.defaultdict(list) for ob in m3.Objects: nm=ob.Attributes.Name or '' g=ob.Geometry if not nm.startswith('P1-RC-') or isinstance(g,rhino3dm.Brep): continue p=nm.split('-'); mk=p[2] if mk not in want: continue segs=[g.SegmentCurve(i) for i in range(g.SegmentCount)] if hasattr(g,'SegmentCount') else [g] desc=[] for s in segs: t=type(s).__name__ a=s.PointAtStart; b=s.PointAtEnd ch=math.sqrt((a.X-b.X)**2+(a.Y-b.Y)**2+(a.Z-b.Z)**2) if t=='ArcCurve': desc.append(('A',round(s.Arc.Radius,1),round(s.Arc.AngleDegrees,1),round(s.Arc.Length,1))) else: desc.append(('L',round(ch,1))) S[mk].append(desc) for mk in want: L=S.get(mk,[]) if not L: continue lines=collections.Counter(); arcs=collections.Counter() for d in L: for e in d: if e[0]=='L': lines[round(e[1])]+=1 else: arcs[(e[1],e[2],e[3])]+=1 o.write(u'%s n=%d 직선 길이 분포 %s\n 호 %s\n'%(mk,len(L),sorted(lines.items())[:25],sorted(arcs.items())[:10])) o.close()