#! python3 # read-only: footing rebar marks of Sanoe / Okseong modified models (dia, direction, z) + footing solid extents import os, json, collections, traceback import Rhino BASE = r"D:\★Pier 자료\프로그램\Pier_T\검토파일" FILES = { "sanoe": os.path.join(BASE, "검토_산외교P1", "산외교P1 G5_수정_20261023.3dm"), "okseong": os.path.join(BASE, "검토_옥성교P1", "옥성교P1_G5_수정_20261023.3dm"), } OUT = r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work\c1_footscan.json" res = {} try: for key, p 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} foot = [] marks = collections.OrderedDict() layers = sorted(set(l.FullPath for l in doc.Layers if "기초" in l.FullPath)) for o in doc.Objects.GetObjectList(st): g = o.Geometry L = lay.get(o.Attributes.LayerIndex, "") if isinstance(g, Rhino.Geometry.Brep) and L.endswith("기초") and "철근" not in L: bb = g.GetBoundingBox(True) foot.append([o.Attributes.Name, L, [round(x, 1) for x in (bb.Min.X, bb.Min.Y, bb.Min.Z, bb.Max.X, bb.Max.Y, bb.Max.Z)]]) if isinstance(g, Rhino.Geometry.Curve) and "중심선" in L: m = o.Attributes.GetUserString("mark") or "" if not m.upper().startswith("B"): continue bb = g.GetBoundingBox(True) d = marks.setdefault(m, {"dia": o.Attributes.GetUserString("dia"), "shape": o.Attributes.GetUserString("shape"), "host": o.Attributes.GetUserString("host"), "n": 0, "mn": [1e12] * 3, "mx": [-1e12] * 3, "src": (o.Attributes.GetUserString("src") or "")[:160], "design_length": o.Attributes.GetUserString("design_length"), "zr_samples": collections.Counter()}) d["n"] += 1 for i, (a, b) in enumerate(((bb.Min.X, bb.Max.X), (bb.Min.Y, bb.Max.Y), (bb.Min.Z, bb.Max.Z))): d["mn"][i] = min(d["mn"][i], a) d["mx"][i] = max(d["mx"][i], b) d["zr_samples"]["%.1f..%.1f" % (bb.Min.Z, bb.Max.Z)] += 1 for m, d in marks.items(): d["mn"] = [round(x, 1) for x in d["mn"]] d["mx"] = [round(x, 1) for x in d["mx"]] d["zr_samples"] = dict(d["zr_samples"].most_common(4)) res[key] = {"footing_solids": foot, "layers": layers, "marks": marks} 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)