#! python3 # read-only: shape of the footing shear / vertical / loop bars of Sanoe (B7-B10) and Okseong (B9-B12), first bar of each mark import os, json, math, collections, traceback import Rhino BASE = r"D:\★Pier 자료\프로그램\Pier_T\검토파일" FILES = { "sanoe": (os.path.join(BASE, "검토_산외교P1", "산외교P1 G5_수정2_20261026.3dm"), ["B7", "B8", "B9", "B10"]), "okseong": (os.path.join(BASE, "검토_옥성교P1", "옥성교P1_G5_수정2_20261026.3dm"), ["B9", "B10", "B11", "B12"]), } OUT = r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work\c1_shear_scan.json" res = {} try: for key, (p, marks) in FILES.items(): doc = Rhino.RhinoDoc.OpenHeadless(p) st = Rhino.DocObjects.ObjectEnumeratorSettings() st.HiddenObjects = True; st.LockedObjects = True; st.NormalObjects = True lay = {l.Index: l.FullPath for l in doc.Layers} fb = [o for o in doc.Objects.GetObjectList(st) if o.Attributes.Name == "P1-FT"][0].Geometry.GetBoundingBox(True) out = {} for o in doc.Objects.GetObjectList(st): g = o.Geometry if not (isinstance(g, Rhino.Geometry.Curve) and "중심선" in lay.get(o.Attributes.LayerIndex, "")): continue a = o.Attributes m = a.GetUserString("mark") if m not in marks: continue d = out.setdefault(m, {"n": 0, "dia": a.GetUserString("dia"), "shape": a.GetUserString("shape"), "design_length": a.GetUserString("design_length"), "src": (a.GetUserString("src") or "")[:300], "samples": []}) d["n"] += 1 if len(d["samples"]) < 2: segs = [] if isinstance(g, Rhino.Geometry.PolyCurve): for i in range(g.SegmentCount): s = g.SegmentCurve(i) ok, arc = s.TryGetArc() p0, p1 = s.PointAtStart, s.PointAtEnd if ok and not s.IsLinear(): segs.append(["arc", round(arc.Radius, 2), round(math.degrees(arc.Angle), 1), [round(p0.X - 0, 1), round(p0.Y, 1), round(p0.Z - fb.Min.Z, 1)], [round(p1.X, 1), round(p1.Y, 1), round(p1.Z - fb.Min.Z, 1)]]) else: segs.append(["line", round(s.GetLength(), 1), None, [round(p0.X, 1), round(p0.Y, 1), round(p0.Z - fb.Min.Z, 1)], [round(p1.X, 1), round(p1.Y, 1), round(p1.Z - fb.Min.Z, 1)]]) d["samples"].append({"name": a.Name, "len": round(g.GetLength(), 1), "segs": segs}) res[key] = out doc.Dispose() except Exception: res["error"] = traceback.format_exc() res["done"] = True json.dump(res, open(OUT, "w", encoding="utf-8"), ensure_ascii=False, indent=1)