import sys, io, json, math, collections; sys.path.insert(0,'pylib') import rhino3dm m3=rhino3dm.File3dm.Read(r"D:\★Pier 자료\심수석님 검토 파일\검토_산외교P1\산외교P1 G5.3dm") bars=collections.defaultdict(list) for o in m3.Objects: g=o.Geometry if isinstance(g,rhino3dm.Brep) or not hasattr(g,'PointAtStart'): continue us=dict(o.Attributes.GetUserStrings()) mk=us.get('mark') if not mk: continue bb=g.GetBoundingBox() bars[mk].append({'name':o.Attributes.Name,'bb':[round(v,1) for v in (bb.Min.X,bb.Min.Y,bb.Min.Z,bb.Max.X,bb.Max.Y,bb.Max.Z)],'dia':us.get('dia'),'shape':us.get('shape'),'host':us.get('host'), 'p0':[round(v,1) for v in (g.PointAtStart.X,g.PointAtStart.Y,g.PointAtStart.Z)],'p1':[round(v,1) for v in (g.PointAtEnd.X,g.PointAtEnd.Y,g.PointAtEnd.Z)]}) json.dump(bars,open('swpos.json','w',encoding='utf-8'),ensure_ascii=False) print({k:len(v) for k,v in bars.items()})