Files
Pier_v1/Code/review_pipeline/cap.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

121 lines
4.1 KiB
Python

# exec'd inside Rhino via execute_rhino_code: g={}; exec(open(path,encoding='utf-8').read(), g); g['run'](shot)
import scriptcontext as sc
import Rhino
import System
from System.Drawing import Size, Color
SCR = r"C:\Users\User\AppData\Local\Temp\claude\D--Rhino-MCP-rhino-mcp-main\f46b47bc-9105-4079-9b62-fcbee31b26ae\scratchpad"
OUT = SCR + r"\shots"
def all_objs():
st = Rhino.DocObjects.ObjectEnumeratorSettings()
st.HiddenObjects = True
st.NormalObjects = True
st.LockedObjects = True
st.IncludeLights = False
st.IncludeGrips = False
return sc.doc.Objects.GetObjectList(st)
def state_path():
return SCR + r"\hidden_state.txt"
def save_state():
doc = sc.doc
ids = []
for o in doc.Objects.GetObjectList(Rhino.DocObjects.ObjectEnumeratorSettings()):
pass
return None
def run(shot):
doc = sc.doc
import os
if not os.path.isdir(OUT):
os.makedirs(OUT)
layers = shot["layers"] # list of layer-path prefixes to show
names = shot.get("names") # optional name substrings (applies to rebar objects only)
show_solids = shot.get("solids", []) # exact layer paths of concrete to show
for o in all_objs():
ln = doc.Layers[o.Attributes.LayerIndex].FullPath
vis = False
for s in show_solids:
if ln == s:
vis = True
for p in layers:
if ln == p or ln.startswith(p + "::"):
if names:
ok = False
for n in names:
if n in o.Name:
ok = True
if ok:
vis = True
else:
vis = True
# skip centerline curves unless asked
if "중심선" in ln and not shot.get("centerline", False):
vis = False
if vis:
doc.Objects.Show(o, True)
else:
doc.Objects.Hide(o, True)
view = doc.Views.ActiveView
vp = view.ActiveViewport
mode = None
for d in Rhino.Display.DisplayModeDescription.GetDisplayModes():
if d.EnglishName == shot.get("mode", "Ghosted"):
mode = d
if mode:
vp.DisplayMode = mode
pr = shot["view"]
if pr == "Front":
vp.SetProjection(Rhino.Display.DefinedViewportProjection.Front, "Front", False)
elif pr == "Right":
vp.SetProjection(Rhino.Display.DefinedViewportProjection.Right, "Right", False)
elif pr == "Top":
vp.SetProjection(Rhino.Display.DefinedViewportProjection.Top, "Top", False)
else:
vp.SetProjection(Rhino.Display.DefinedViewportProjection.Perspective, "Perspective", False)
c = shot["cam"]
vp.SetCameraLocations(Rhino.Geometry.Point3d(c[3], c[4], c[5]), Rhino.Geometry.Point3d(c[0], c[1], c[2]))
b = shot["box"]
bb = Rhino.Geometry.BoundingBox(Rhino.Geometry.Point3d(b[0], b[1], b[2]), Rhino.Geometry.Point3d(b[3], b[4], b[5]))
vp.ZoomBoundingBox(bb)
view.Redraw()
vs = vp.Size
k = shot.get("k", 2.0)
w = int(vs.Width * k)
h = int(vs.Height * k)
bmp = view.CaptureToBitmap(Size(w, h), False, False, False)
bmp.Save(OUT + "\\" + shot["file"])
xf = vp.GetTransform(Rhino.DocObjects.CoordinateSystem.World, Rhino.DocObjects.CoordinateSystem.Screen)
res = []
for p in shot.get("pts", []):
q = Rhino.Geometry.Point3d(p[0], p[1], p[2])
q.Transform(xf)
res.append("%.1f,%.1f" % (q.X * k, q.Y * k))
open(OUT + "\\" + shot["file"] + ".txt", "w").write(("%d,%d" % (w, h)) + chr(10) + chr(10).join(res))
return shot["file"]
def restore():
doc = sc.doc
f3 = Rhino.FileIO.File3dm.Read(doc.Path)
hid = set()
for ob in f3.Objects:
if not ob.Attributes.Visible:
hid.add(str(ob.Attributes.ObjectId))
f3.Dispose()
n = 0
for o in all_objs():
if str(o.Id) in hid:
doc.Objects.Hide(o, True)
n += 1
else:
doc.Objects.Show(o, True)
doc.Views.Redraw()
return n