main
John Lauer Review component pin functions and validate isolated library model and hole corrections 7fb4d36
"""Native headless STEP export of the isolated catalog-model candidate."""
from pathlib import Path
import subprocess,json,zipfile,base64
root=Path(__file__).resolve().parents[1];out=root/'checkpoints/library-model-review';remote='C:/Users/john/adom-projects/adom-custom-electronic-load/review/library-model-candidate'
def call(v,a,label):
 p=subprocess.run(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',v,json.dumps(a)],capture_output=True,text=True)
 d=json.loads(p.stdout);(out/(label+'.json')).write_text(json.dumps(d,indent=2)+'\n')
 assert p.returncode==0 and d.get('success',d.get('ok',True)) and not d.get('errors') and d.get('exitCode',0)==0,d
 return d
archive=out/'candidate-inputs.zip'
with zipfile.ZipFile(archive,'w',zipfile.ZIP_DEFLATED) as z:
 for p in out.rglob('*'):
  if p.is_file() and (p.suffix in ['.step','.kicad_pcb','.kicad_pro','.kicad_dru','.kicad_mod'] or p.name=='fp-lib-table'):z.write(p,p.relative_to(out))
call('send_files',{'filePaths':[str(archive)],'dest':remote+'/','reason':'Transfer isolated nominal-model candidate for native STEP export'},'send-inputs')
cli=call('kicad_status',{},'native-status')['install']['kicadCli']
script=f"$ErrorActionPreference='Stop'\nExpand-Archive -LiteralPath '{remote}/candidate-inputs.zip' -DestinationPath '{remote}' -Force\n& '{cli}' pcb export step --subst-models --output '{remote}/library-model-candidate.step' '{remote}/library-model-candidate.kicad_pcb'\nexit $LASTEXITCODE\n"
call('run_script',{'interpreter':'powershell','scriptB64':base64.b64encode(script.encode()).decode(),'timeoutSeconds':120,'reason':'Native STEP export for model position review; no open board is changed'},'native-export')
call('pull_file',{'filePaths':[remote+'/library-model-candidate.step'],'saveTo':str(out)},'pull-step')
print('Native STEP exported; visual model review pending')