main
John Lauer Publish compact v5 probe-driven placement and explicit incomplete cooling screen 37f2cbf
"""Add explicitly provisional cooling reservations to a separate probe experiment."""
from pathlib import Path
import json,copy,shutil,argparse
ap=argparse.ArgumentParser();ap.add_argument("--stem",default="compact-v4");ap.add_argument("--board",default="compact-native-v4.kicad_pcb");ap.add_argument("--side-fan",action="store_true");ap.add_argument("--source-stem");args=ap.parse_args();assert Path(args.stem).name==args.stem and Path(args.board).name==args.board
import cadquery as cq
from glb_shape_helpers import read_glb,write_glb,add_shape
R=Path(__file__).resolve().parents[1];D=R/'revisions/compact-r11';src=D/'kicad'/((args.source_stem or args.stem)+'-molecule.plain.glb');out=D/'kicad'/(args.stem+'-cooling-reservations.glb')
g,b=read_glb(src);root=len(g['nodes']);g['nodes'].append({'name':'PROVISIONAL cooling reservations - no clamp or harness','children':[]});g['scenes'][g.get('scene',0)]['nodes'].append(root)
# Native board lower-left frame -> MP1 anchor; nominal step2glb Z shift.
items=[('Heatsink_main_body_RESERVATION',[18,23,8.845],[40,40,35],(.4,.65,.9)),('Fan_body_RESERVATION',[18,9.4,6],[40,10.6,40],(.15,.6,.55))]
if args.side_fan:
 items=[('Heatsink_main_body_RESERVATION',[20.5,24,8.845],[40,40,35],(.4,.65,.9)),('Fan_body_RESERVATION',[61,24,6],[10.6,40,40],(.15,.6,.55))]
for name,xyz,size,col in items:
 shape=cq.Workplane('XY').box(*size,centered=(False,False,False)).translate((xyz[0]-4,xyz[1]-4,xyz[2]+4.005)).val()
 add_shape(g,b,shape,name,col,root,'Envelope only. No verified clamp, sink ears, duct or routed fan lead. Not final assembly.')
g['asset'].setdefault('extras',{})['reviewScope']='Provisional main-body cooling reservations only; not final component geometry or assembled qualification';write_glb(out,g,b)
p=D/('probing-'+args.stem+'-reservations')/'probing-flow';shutil.copytree(D/'probing/probing-flow',p,dirs_exist_ok=True)
state=json.loads((p/'state.json').read_text());state['probing']['glb']=str(out);state['probing']['board']=str(D/'kicad'/args.board);state['release']['board']={'path':state['probing']['board'],'sha256':__import__('hashlib').sha256(Path(state['probing']['board']).read_bytes()).hexdigest()};state['reviewScope']='Provisional main-body sink/fan reservations. Clamp, ears, duct, sensor and fan harness missing. Not assembled acceptance.';(p/'state.json').write_text(json.dumps(state,indent=2)+'\n')
# A copied project is a proposal, not fresh evidence. Regenerate access,
# stack, compile and every downstream result for the new board and obstacles.
for q in ['access.json','stack.json','sequence.json','collide.json','margins.json','coverage.json','stack.ok','compile.ok','collide.ok','margins.ok','coverage.ok']:
 (p/q).unlink(missing_ok=True)
plan=json.loads((p/'plan.json').read_text());plan['board']=state['probing']['board'];plan['status']='Unqualified proposal; regenerate access and compile before replay';(p/'plan.json').write_text(json.dumps(plan,indent=2)+'\n')
shutil.copy2(out,out.with_suffix('.plain.glb'))
meta=src.with_name(src.name.replace('.plain.glb','_footprint.json'))
if meta.exists():shutil.copy2(meta,out.with_name(out.stem+'_footprint.json'))
(D/'evidence'/(args.stem+'-cooling-reservation-geometry.json')).write_text(json.dumps({'source':str(src),'output':str(out),'nativeFrameReservations':items,'anchorOffsetMm':[-4,-4,4.005],'limitations':state['reviewScope']},indent=2)+'\n')
print(out)