# execute_rhino_code (IronPython 2.7) - 코핑 로컬 프레임 + 길이방향 단면 외곽 (s, z) 출력 # 입력: COPING_ID import scriptcontext as sc, Rhino, math, System d = sc.doc tol = d.ModelAbsoluteTolerance COPING_ID = "d7b51436-d411-4ed6-be00-5af9d2058029" b = d.Objects.FindId(System.Guid(COPING_ID)).Geometry # 1) 길이방향 각도: 수평 edge 방향 히스토그램 angs = {} for e in b.Edges: v = e.PointAtEnd - e.PointAtStart if abs(v.Z) < 1 and v.Length > 1000: a = round(math.degrees(math.atan2(v.Y, v.X)) % 180.0, 3) angs[a] = angs.get(a, 0) + v.Length out = [] for k in sorted(angs.keys()): out.append("ang %s total len %d" % (k, round(angs[k]))) # 길이방향 = bbox 범위와 맞는 쪽 선택 (대호지교 P1: 19.105) ANG = 19.105 a = math.radians(ANG) u = Rhino.Geometry.Vector3d(math.cos(a), math.sin(a), 0) c = b.GetBoundingBox(True).Center # 2) 단면 pl = Rhino.Geometry.Plane(c, u, Rhino.Geometry.Vector3d.ZAxis) ok, crvs, pts = Rhino.Geometry.Intersect.Intersection.BrepPlane(b, pl, tol) for sg in crvs[0].DuplicateSegments(): p0 = sg.PointAtStart; p1 = sg.PointAtEnd out.append("%.1f,%.1f -> %.1f,%.1f" % ((p0 - c) * u, p0.Z, (p1 - c) * u, p1.Z)) sc.sticky["frame"] = (ANG, c) result = "\n".join(out) print(result)