AnasSarkiz/NEMA14_CH32X035G8U6

A NEMA stepper motor is shown with proposed M3 screws/spacers, four wired motor leads and splices, and a JST SHR-04V-S connector.

Version
1.12.2
License
ISC
Stars
0

scripts/sync-source.py

"""Refresh annotations from the rendered source without changing checked copper geometry."""
import json,pathlib
root=pathlib.Path(__file__).resolve().parents[1];p=root/'artifacts/board.circuit.json'
a=json.loads(p.read_text());b=json.loads((root/'artifacts/final-source.circuit.json').read_text())
for typ in ['pcb_smtpad','pcb_plated_hole','pcb_port','source_port','source_net']:
 key=typ+'_id';aa={e[key]:e for e in a if e['type']==typ};bb={e[key]:e for e in b if e['type']==typ};assert aa.keys()==bb.keys(),typ
 for k,x in aa.items():
  for prop in ['x','y','width','height','outer_width','outer_height','hole_diameter','outer_diameter','name','source_component_id','source_port_id','pcb_component_id','subcircuit_connectivity_map_key']:
   v=x.get(prop);w=bb[k].get(prop)
   assert abs(v-w)<1e-4 if isinstance(v,(int,float)) and isinstance(w,(int,float)) else v==w,(typ,k,prop,v,w)
assert not any(e['type'].endswith('_error') for e in b)
j=[e for e in b if e['type'] not in ['pcb_trace','pcb_via','pcb_copper_pour']]+[e for e in a if e['type'] in ['pcb_trace','pcb_via']]
for e in j:
 if e['type']=='pcb_board':e['is_via_in_pad_allowed']=True
 if e['type']=='pcb_via':e['tented_on_bottom']=True;e['tented_on_top']=True
p.write_text(json.dumps(j,indent=2)+'\n');print('Source geometry matches saved copper; refreshed annotations.')