main
John Lauer
Preserve board29, component assets and scaffold-fit correction candidate with reviewed footage
c54169e
"""Original nominal off-board housings and loose contact; not manufacturer CAD.
Dimensions transcribed from primary Harwin drawings. Internal details approximate.
"""
from pathlib import Path
import cadquery as cq
import json,shutil,hashlib
R=Path(__file__).resolve().parents[1]
for n in [2,3]:
slug=f'm20-1060{n}00';P=R/'components'/slug;P.mkdir(exist_ok=True)
length=2.54*n+.2
body=cq.Workplane('XY').box(length,2.5,14,centered=(True,True,False))
# Simplified socket passages; not dimensioned by vendor drawing, no fit claim.
for i in range(n):
x=(i-(n-1)/2)*2.54
body=body.cut(cq.Workplane('XY').box(1.7,1.55,14.2,centered=(True,True,False)).translate((x,0,-.1)))
assy=cq.Assembly(name=slug+'_NOMINAL');assy.add(body,name='Housing',color=cq.Color(.055,.06,.065));assy.save(str(P/(slug+'.step')))
report={'mpn':slug.upper(),'modelClass':'original nominal drawing-led exterior; approximate cavities','dimensionsMm':{'length':length,'width':2.5,'height':14,'pitch':2.54},'tolerancesMm':{'length':.3,'width':.2,'height':.2},'coordinateFrame':'Z0 mating face; Z14 wire insertion; contact1 at negative X; no contacts included','cavitiesMm':[1.7,1.55],'cavityDimensions':'illustrative, not manufacturing/engagement evidence','matingPinLengthMm':[5.5,6.3],'matingPinSquareMm':.64,'electricalRatingAppliesOnlyWithSpecifiedContacts':True,'validSolids':all(s.isValid() for s in body.val().Solids()),'limitations':['No vendor CAD license acquired; TraceParts download requires registered email.','Cavity steps, latches, chamfers and mold mark not dimensionally qualified.','No PCB solder pads: off-board housing.','Crimp/contact insertion and mating tolerance qualification remain open.']}
(P/'review/model-review.json').write_text(json.dumps(report,indent=2)+'\n')
# Mechanical-only overlay. Not an electrically usable PCB footprint.
fp=f'''(footprint "{slug.upper()}_MECHANICAL_ONLY" (version 20240108) (generator "adom") (layer "F.Cu")
(descr "Off-board housing envelope. No copper pads. Do not place as a PCB connector.")
(attr board_only exclude_from_pos_files exclude_from_bom)
(fp_rect (start {-length/2} -1.25) (end {length/2} 1.25) (stroke (width 0.1) (type default)) (fill none) (layer "F.Fab"))
(fp_rect (start {-length/2-.25} -1.5) (end {length/2+.25} 1.5) (stroke (width 0.05) (type default)) (fill none) (layer "F.CrtYd"))
(model "${{KIPRJMOD}}/{slug}.step" (offset (xyz 0 0 0)) (scale (xyz 1 1 1)) (rotate (xyz 0 0 0)))
)'''
(P/(slug+'-mechanical.kicad_mod')).write_text(fp+'\n')
# Harness documentation symbol has contact positions, on_board no.
s=(R/'components'/f'm20-9990{n}46'/f'm20-9990{n}46.kicad_sym').read_text().replace(f'M20-9990{n}46',slug.upper()).replace('(on_board yes)','(on_board no)')
(P/(slug+'-harness.kicad_sym')).write_text(s)
# Mating PCB footprint is a distinct exact part and remains explicitly named.
mate=f'm20-9990{n}46';shutil.copy2(R/'components'/mate/(mate+'.kicad_mod'),P/(mate+'-MATING-PCB.kicad_mod'))
print(slug,report['validSolids'])
# Original loose contact illustration with nominal published sections.
P=R/'components/m20-1180046';slug=P.name
# Socket outer1.65x1.50, length4.50; approximate wall0.15, not spring proof.
socket=cq.Workplane('XY').box(1.65,1.50,4.5,centered=(True,True,False)).cut(cq.Workplane('XY').box(1.35,1.20,4.7,centered=(True,True,False)).translate((0,0,-.1)))
spine=cq.Workplane('XY').box(1.2,.15,7.2,centered=(True,False,False)).translate((0,-.75,4.5))
# Open wings approximate uncrimped conductor/insulation barrels.
shapes=[('Socket_approx',socket),('Spine_approx',spine)]
for z,w,h,l in [(5.0,1.7,1.7,2.4),(10.0,2.3,2.6,1.7)]:
# Continuous open barrel with joined back and flared wings, rather than floating plates.
x=w/2;inner=.38;outer=.50;y0=-.75;yt=y0+h
pts=[(-x,yt),(-outer,y0),(outer,y0),(x,yt),(x-.15,yt),(inner,y0+.15),(-inner,y0+.15),(-x+.15,yt)]
barrel=cq.Workplane('XY').polyline(pts).close().extrude(l).translate((0,0,z))
shapes.append((f'Open_barrel_{z}',barrel))
a=cq.Assembly(name='M20_1180046_LOOSE_APPROX')
for name,shape in shapes:a.add(shape,name=name,color=cq.Color(.72,.73,.75))
a.save(str(P/(slug+'.step')))
report={'mpn':'M20-1180046','status':'illustrative original model; not mating/crimp geometry','dimensionsMm':{'nominalLength':11.7,'drawingReferenceOverall':12.04,'insulationWingWidth':2.3,'insulationWingHeight':2.6,'socketSection':[1.65,1.5],'socketLength':4.5},'wireAWG':[22,24,26,28,30],'insulationDiameterMm':[.9,1.6],'stripLengthMm':[3,4],'conductorCrimpHeightMm':{'26-30AWG':[.69,.75],'22-24AWG':[.83,.89]},'handTool':'Z20-320','limitations':['Model omits spring tongue, formed curves and retention latch.','Not suitable to prove mating fit or crimp geometry.','Loose uncrimped appearance differs from installed contact; create qualified installed variant separately.','No copper footprint: cable termination only.']}
(P/'review/model-review.json').write_text(json.dumps(report,indent=2)+'\n')
print(slug,'illustrative')