Files
Pier_v1/Code/검토수정/스크립트/c1_hookend_capture.py
T
ahnyongjooandClaude Sonnet 5.5 964a841de1 chore(rebar): Pier_T_rebar 작업 폴더 초기 구성 및 외부 의존 파일 통합
- Code\rebar_pipeline, review_pipeline, pier-program을 정션에서 실제 폴더로 전환
- Code\rhino_mcp 및 CLAUDE_rhino배경.md 추가, .mcp.json은 PYTHONPATH로 새 위치 사용
- pier-program 내부 .git 제거(이력은 backup\pier-program_20261028.bundle에 보관)
- worktree 가이드 반영(CLAUDE.local.md, HANDOFF.md)
- D:\Rhino-MCP 경로 참조를 새 위치로 치환

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 11:20:18 +09:00

83 lines
4.1 KiB
Python

#! python3
# capture one representative bar (median of the mark) of Sanoe coping shear marks, before (수정2) or after (수정4) the lap rebuild
import os, json, math, traceback, re
import Rhino
import Rhino.Geometry as rg
import System
import System.Drawing
HERE = os.path.dirname(os.path.abspath(__file__))
cfg = json.load(open(os.path.join(HERE, "lap_cfg.json"), encoding="utf-8"))
res = {"tag": cfg["tag"], "items": {}}
try:
doc = Rhino.RhinoDoc.ActiveDoc
st = Rhino.DocObjects.ObjectEnumeratorSettings()
st.HiddenObjects = True; st.LockedObjects = True; st.NormalObjects = True
for l in doc.Layers:
if not l.IsDeleted:
doc.Layers.ForceLayerVisible(l.Index)
allobjs = list(doc.Objects.GetObjectList(st))
strip = re.compile(r"-(뚜껑|바닥|좌|우)$")
view = doc.Views.ActiveView
vp = view.ActiveViewport
for job in cfg["jobs"]:
mark, vname = job["mark"], job["view"]
bases = {}
for o in allobjs:
if isinstance(o.Geometry, rg.Brep) and o.Attributes.GetUserString("mark") == mark and o.Attributes.GetUserString("host") != "P1-FT":
bases.setdefault(strip.sub("", o.Attributes.Name), []).append(o)
names = sorted(bases.keys())
base = names[len(names) // 2]
targets = bases[base]
ids = set(o.Id for o in targets)
for o in allobjs:
if o.Id in ids:
doc.Objects.Show(o, True)
else:
doc.Objects.Hide(o, True)
# colour the pieces differently (display only, file is not saved)
cols = [System.Drawing.Color.FromArgb(214, 39, 40), System.Drawing.Color.FromArgb(31, 119, 180)]
for i, o in enumerate(sorted(targets, key=lambda q: q.Attributes.Name)):
at = o.Attributes.Duplicate()
at.ColorSource = Rhino.DocObjects.ObjectColorSource.ColorFromObject
at.ObjectColor = cols[i % 2] if len(targets) > 1 else System.Drawing.Color.FromArgb(31, 119, 180)
doc.Objects.ModifyAttributes(o, at, True)
bb = rg.BoundingBox.Empty
for o in targets:
bb.Union(o.Geometry.GetBoundingBox(True))
if vname == "auto":
dx = bb.Max.X - bb.Min.X
dy = bb.Max.Y - bb.Min.Y
vname = "Right" if dx < 0.05 * dy else ("Front" if dy < 0.05 * dx else "Top")
proj = {"Top": Rhino.Display.DefinedViewportProjection.Top, "Front": Rhino.Display.DefinedViewportProjection.Front, "Right": Rhino.Display.DefinedViewportProjection.Right}[vname]
vp.SetProjection(proj, vname, False)
vp.DisplayMode = Rhino.Display.DisplayModeDescription.FindByName("Shaded") or vp.DisplayMode
w = job.get("where", "all")
if w == "all":
bb2 = rg.BoundingBox(bb.Min, bb.Max)
bb2.Inflate(max(150.0, 0.06 * bb.Diagonal.Length))
else:
xx = {"start": bb.Min.X, "end": bb.Max.X, "mid": (bb.Min.X + bb.Max.X) / 2.0}[w]
hw = 650.0
bb2 = rg.BoundingBox(rg.Point3d(xx - hw, bb.Min.Y - 80, bb.Min.Z - 80), rg.Point3d(xx + hw, bb.Max.Y + 80, bb.Max.Z + 80))
vp.ZoomBoundingBox(bb2)
view.Redraw()
Rhino.RhinoApp.Wait()
cw, ch = vp.Size.Width, vp.Size.Height
W = 1500
H = int(round(W * ch / float(cw)))
sc = W / float(cw)
bmp = view.CaptureToBitmap(System.Drawing.Size(W, H))
png = os.path.join(cfg["out"], "%s_%s_%s.png" % (cfg["tag"], mark, job.get("where", "all")))
bmp.Save(png, System.Drawing.Imaging.ImageFormat.Png)
res["items"][mark + "_" + job.get("where", "all")] = {"png": png, "base": base, "pieces": len(targets), "size": [bmp.Width, bmp.Height], "view": vname,
"bbox": [bb.Min.X, bb.Min.Y, bb.Min.Z, bb.Max.X, bb.Max.Y, bb.Max.Z]}
except Exception:
res["error"] = traceback.format_exc()
res["done"] = True
json.dump(res, open(os.path.join(cfg["out"], "%s_capture.json" % cfg["tag"]), "w", encoding="utf-8"), ensure_ascii=False, indent=1)
try:
Rhino.RhinoDoc.ActiveDoc.Modified = False
except Exception:
pass