- 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>
71 lines
3.3 KiB
Python
71 lines
3.3 KiB
Python
#! python3
|
|
# capture Front / Right viewport images of the footing rebar of a modified model + projected pixel positions of reference heights.
|
|
# config: cap_cfg.json next to this script: {"key": ..., "out": dir, "zlines": [[label, z_rel], ...]}
|
|
import os, json, traceback
|
|
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, "cap_cfg.json"), encoding="utf-8"))
|
|
res = {"key": cfg["key"]}
|
|
try:
|
|
doc = Rhino.RhinoDoc.ActiveDoc
|
|
res["doc"] = doc.Path
|
|
# layers: footing concrete + footing rebar only
|
|
for l in doc.Layers:
|
|
if l.IsDeleted:
|
|
continue
|
|
p = l.FullPath
|
|
show = p.startswith("P1::철근::기초") or p == "P1" or p == "P1::철근" # footing concrete hidden so the rebar is visible
|
|
doc.Layers.ForceLayerVisible(l.Index) if show else None
|
|
if not show:
|
|
l.IsVisible = False
|
|
st = Rhino.DocObjects.ObjectEnumeratorSettings()
|
|
st.HiddenObjects = True; st.LockedObjects = True; st.NormalObjects = True
|
|
foot = [o for o in doc.Objects.GetObjectList(st) if o.Attributes.Name == "P1-FT"][0]
|
|
for o in doc.Objects.GetObjectList(st): # make sure footing objects themselves are shown
|
|
L = doc.Layers[o.Attributes.LayerIndex].FullPath
|
|
if L.startswith("P1::철근::기초"):
|
|
doc.Objects.Show(o, True)
|
|
fb = foot.Geometry.GetBoundingBox(True)
|
|
res["footing_bbox"] = [fb.Min.X, fb.Min.Y, fb.Min.Z, fb.Max.X, fb.Max.Y, fb.Max.Z]
|
|
view = doc.Views.ActiveView
|
|
out = {}
|
|
for name, proj in (("Front", Rhino.Display.DefinedViewportProjection.Front), ("Right", Rhino.Display.DefinedViewportProjection.Right)):
|
|
vp = view.ActiveViewport
|
|
vp.SetProjection(proj, name, False)
|
|
vp.DisplayMode = Rhino.Display.DisplayModeDescription.FindByName("Shaded") or vp.DisplayMode
|
|
bb = rg.BoundingBox(fb.Min, fb.Max)
|
|
bb.Inflate(300.0)
|
|
vp.ZoomBoundingBox(bb)
|
|
view.Redraw()
|
|
Rhino.RhinoApp.Wait()
|
|
cw, ch = vp.Size.Width, vp.Size.Height
|
|
W = 1800
|
|
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.png" % (cfg["key"], name))
|
|
bmp.Save(png, System.Drawing.Imaging.ImageFormat.Png)
|
|
info = {"png": png, "size": [bmp.Width, bmp.Height], "client": [cw, ch], "scale": sc, "lines": {}}
|
|
zb = fb.Min.Z
|
|
for label, zrel in cfg["zlines"]:
|
|
if name == "Front":
|
|
a, b = rg.Point3d(fb.Min.X, 0, zb + zrel), rg.Point3d(fb.Max.X, 0, zb + zrel)
|
|
else:
|
|
a, b = rg.Point3d(0, fb.Min.Y, zb + zrel), rg.Point3d(0, fb.Max.Y, zb + zrel)
|
|
pa, pb = vp.WorldToClient(a), vp.WorldToClient(b)
|
|
info["lines"][label] = [[pa.X * sc, pa.Y * sc], [pb.X * sc, pb.Y * sc]]
|
|
out[name] = info
|
|
res["views"] = out
|
|
except Exception:
|
|
res["error"] = traceback.format_exc()
|
|
res["done"] = True
|
|
json.dump(res, open(os.path.join(cfg["out"], "%s_capture.json" % cfg["key"]), "w", encoding="utf-8"), ensure_ascii=False, indent=1)
|
|
try:
|
|
Rhino.RhinoDoc.ActiveDoc.Modified = False
|
|
except Exception:
|
|
pass
|