import sys; sys.path.insert(0,"./pylib"); sys.stdout.reconfigure(encoding='utf-8') import rhino3dm, numpy as np, math m=rhino3dm.File3dm.Read('m.3dm'); byidx={l.Index:l.FullPath for l in m.Layers} L=('P1::받침대좌','P1::받침패드','P1::교량받침','P1::솔플레이트') res={} for o in m.Objects: p=byidx.get(o.Attributes.LayerIndex) if p not in L: continue g=o.Geometry pts=[] try: for fi in range(len(g.Faces)): k=g.Faces[fi].GetMesh(rhino3dm.MeshType.Any) if k is None: continue pts+= [(v.X,v.Y,v.Z) for v in k.Vertices] except Exception as e: bb=g.GetBoundingBox(); pts=[(bb.Min.X,bb.Min.Y,bb.Min.Z),(bb.Max.X,bb.Max.Y,bb.Max.Z)] P=np.array(pts) xy=P[:,:2]-P[:,:2].mean(axis=0) # find rotation minimizing bbox area best=None for ang in np.arange(-10,10.01,0.05): a=math.radians(ang); R=np.array([[math.cos(a),-math.sin(a)],[math.sin(a),math.cos(a)]]) q=xy@R.T; w=q[:,0].max()-q[:,0].min(); h=q[:,1].max()-q[:,1].min() if best is None or w*h