main
John Lauer Publish 0.1.0 b324771 8d ago
"""Original drawing-led maximum body envelope and nominal straight300mm cable. Not manufacturer CAD."""
from pathlib import Path
import cadquery as cq,json,hashlib,sys
from OCP.Bnd import Bnd_Box
from OCP.BRepBndLib import BRepBndLib
R=Path(__file__).resolve().parent
from glb_shape_helpers import add_shape,write_glb
slug='ntcle428e3103h301a';a=cq.Assembly(name=slug)
g={'asset':{'version':'2.0','generator':'Adom original NTCLE428 nominal cable'},'scene':0,'scenes':[{'nodes':[0]}],'nodes':[{'name':'NTCLE428.Nominal300mm','children':[]}],'buffers':[{'byteLength':0}],'accessors':[]};blob=bytearray()
# Body uses the drawing maximum3x10mm envelope. Rounded nose and flat wire exit are simplified interpretations.
body=cq.Solid.makeCylinder(1.5,8.5,cq.Vector(1.5,0,1.5),cq.Vector(1,0,0)).fuse(cq.Solid.makeSphere(1.5,cq.Vector(1.5,0,1.5),angleDegrees1=-90))
items=[('Sensor.Body.MaximumEnvelope',body,(.045,.045,.05))]
for n,y in enumerate([-.425,.425],1):
 # Leads begin at body rear; wire spacing is illustrative, not drawing-controlled.
 wire=cq.Solid.makeCylinder(.425,287,cq.Vector(10,y,1.5),cq.Vector(1,0,0))
 tip=cq.Solid.makeCylinder(.15,3,cq.Vector(297,y,1.5),cq.Vector(1,0,0))
 items.extend([(f'Lead.{n}.PVC',wire,(.06,.06,.065)),(f'Lead.{n}.SolderDipped',tip,(.65,.67,.70))])
for name,s,col in items:
 assert s.isValid();a.add(s,name=name.replace('.','_'),color=cq.Color(*col));add_shape(g,blob,s,name,col,0,'Original nominal envelope; no connector supplied; wire spacing and capsule profile illustrative')
a.save(str(R/(slug+'.step')));write_glb(R/(slug+'.glb'),g,blob)
s=cq.Compound.makeCompound([s for _,s,_ in items]);bb=Bnd_Box();BRepBndLib.AddOptimal_s(s.wrapped,bb,False,False);x,y,z,X,Y,Z=bb.Get();dims=[X-x,Y-y,Z-z];assert all(abs(a-b)<1e-6 for a,b in zip(dims,[300,3,3])),dims
(R/'model-review.json').write_text(json.dumps({'bboxMm':dims,'boundsMethod':'Exact geometry bounds without triangulation padding','overallNominalLengthMm':300,'bodyMaximumLengthMm':10,'bodyMaximumDiameterMm':3,'externalLeadLengthMm':290,'solderDippedLengthMm':3,'wireNominalODMm':.85,'conductorNominalDiameterMm':.3,'solidCount':len(s.Solids()),'limits':['Rounded body approximates drawing maximum envelope, not exact epoxy shape.','Wire center separation0.85mm illustrative; actual flexible cable pose varies.','Bare sensor has flying solder-dipped leads; no connector or crimp included.','No factory marking; no animation or measured physical/thermal qualification.'],'sha256':{ext:hashlib.sha256((R/(slug+ext)).read_bytes()).hexdigest()for ext in ['.step','.glb']}},indent=2)+'\n')
print('Original300mm cable model generated')