文件
phonerail/.claude/r2/shell/probe_plenum.py
T

39 行
1.4 KiB
Python

# read-only: what lives in the two plenum slices and in the north bypass strip
import sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace', write_through=True)
import win32com.client as wc
def prop(o, n):
v = getattr(o, n)
return v() if type(v).__name__ in ('method','function','builtin_function_or_method') else v
app = wc.GetActiveObject('SldWorks.Application')
doc = app.ActiveDoc
kids = []
for c in doc.GetComponents(False):
nm = prop(c, 'Name2')
if 'BASE-PCB' not in nm.upper() or '/' not in nm:
continue
try:
b = [round(v*1000, 2) for v in c.GetBox(False, False)]
except Exception:
continue
kids.append((nm.split('/')[-1], b))
print('base-PCB children:', len(kids))
def show(title, pred):
sel = [(n,b) for n,b in kids if pred(b)]
sel.sort(key=lambda r: -(r[1][5]))
print('\n== %s : %d parts ==' % (title, len(sel)))
for n,b in sel[:18]:
print(' %-26s x %7.2f~%7.2f y %7.2f~%7.2f z %7.2f~%7.2f' % (n[:26], b[0],b[3], b[1],b[4], b[2],b[5]))
# west plenum slice: everything with x below 6 (blade front is 4.01)
show('WEST plenum slice x < 6', lambda b: b[0] < 6.0)
# east plenum slice
show('EAST plenum slice x > 92', lambda b: b[3] > 92.0)
# north bypass strip: y above 90
show('NORTH strip y > 90', lambda b: b[4] > 90.0)
# south strip (blade1 phone side): y below 8
show('SOUTH strip y < 8', lambda b: b[1] < 8.0)