"""Adjustable direct-console cradle prototype. Dimensions in mm. Sony nominal original disc PS5: 390 high x104 wide x260 deep. No claimed exact underside contour or verified physical fit. """ from pathlib import Path import json import cadquery as cq O=Path(__file__).resolve().parent/'generated' O.mkdir(parents=True,exist_ok=True) parts={}; assembled=[] def box(w,d,h,x=0,y=0,z=0): return cq.Workplane('XY').box(w,d,h,centered=(True,True,False)).translate((x,y,z)) def hole(s,x,y,h=120,z=-1,r=2.75): return s.cut(cq.Workplane('XY').center(x,y).circle(r).extrude(h).translate((0,0,z))) def save(name,s): v=s.val(); assert v.isValid() and len(v.Solids())==1,name b=v.BoundingBox(); assert b.xlen<=250 and b.ylen<=250 and b.zlen<=250,name cq.exporters.export(v,str(O/(name+'.stl')),tolerance=.05,angularTolerance=.1) cq.exporters.export(v,str(O/(name+'.step'))) parts[name]={'size_mm':[round(b.xlen,2),round(b.ylen,2),round(b.zlen,2)],'valid_solid':True} # Upright assembly coordinates, tabletop z100, center seam y0. for sign,label in [(-1,'front'),(1,'rear')]: y=sign*80 s=box(240,160,12,0,y,88) for x in (-94,94): s=s.union(box(52,52,90,x,sign*134,0).edges('|Z').fillet(4)) s=s.union(box(240,10,32,0,sign*155,58)) for x in (-115,115): s=s.union(box(10,160,32,x,y,58)) # Splice fasteners, side shoe fasteners, end-stop fasteners. for x in (-80,80): s=hole(s,x,sign*25) for x in (-76,76): for yy in (sign*55,sign*85): s=hole(s,x,yy) for x in (-18,18): s=hole(s,x,sign*140) # Engraved wood plank seams on top and apron, kept clear of joins. for yy in (sign*40,sign*80,sign*120): s=s.cut(box(210,.8,.6,0,yy,99.4)) for z in (65,78,90): for x in (-93,0,93): s=s.cut(box(44 if x else 116,1,0.8,x,sign*159.7,z)) # Recessed sunset medallion on outer apron. plane=cq.Plane(origin=(0,sign*159.2,76),xDir=(1,0,0),normal=(0,sign,0)) s=s.cut(cq.Workplane(plane).circle(12).circle(10.8).extrude(1.2)) # Cowboy head, hat and coat cut in same front plane. s=s.cut(cq.Workplane(plane).center(0,4).circle(2.2).extrude(1.2)) s=s.cut(cq.Workplane(plane).center(0,6).rect(10,1.5).extrude(1.2)) s=s.cut(cq.Workplane(plane).center(0,7.5).rect(5,3).extrude(1.2)) s=s.cut(cq.Workplane(plane).polyline([(-2,1),(2,1),(5,-7),(-5,-7)]).close().extrude(1.2)) assembled.append(s.val()) # Print on tabletop, legs up; normalize XY and Z. printed=s.rotate((0,0,0),(1,0,0),180).translate((0,y,100)) save('01-'+label+'-platform-print',printed) # Two underside splice bars, four bolts total. bar=box(32,90,8) for yy in (-25,25): bar=hole(bar,0,yy) save('02-splice-bar-print-two',bar) for x in (-80,80): assembled.append(bar.translate((x,0,80)).val()) # Side shoe, local x points away from console; wall face at x0. # Base occupies x0..60; fastening slots permit 38 mm of lateral adjustment. shoe=box(60,46,8,30) shoe=shoe.union(box(8,46,65,4,0,0)) for yy in (-15,15): cutter=cq.Workplane('XY').center(32,yy).slot2D(38,5.5,0).extrude(10) shoe=shoe.cut(cutter) # Outside triangular gussets join wall to base (no console-side protrusion). for yy in (-21,18): pl=cq.Plane(origin=(0,yy,0),xDir=(1,0,0),normal=(0,-1,0)) gus=cq.Workplane(pl).polyline([(8,8),(30,8),(8,48)]).close().extrude(3) shoe=shoe.union(gus) save('03-side-shoe-print-four',shoe) for sign in (-1,1): for yy in (-70,70): obj=shoe if sign==1 else shoe.rotate((0,0,0),(0,0,1),180) assembled.append(obj.translate((sign*56,yy,100)).val()) # Front/back stops are low and adjustable to reduce obstruction of front slot/rear connectors. stop=box(54,38,6,0,19).union(box(54,6,18,0,3)) for x in (-18,18): stop=stop.cut(cq.Workplane('XY').center(x,16).slot2D(28,5.5,90).extrude(10)) save('04-end-stop-print-two',stop) for sign in (-1,1): obj=stop if sign==1 else stop.rotate((0,0,0),(0,0,1),180) assembled.append(obj.translate((0,sign*130,100)).val()) # STEP for inspecting the assembled stand (not a print plate). cq.exporters.export(cq.Compound.makeCompound(assembled),str(O/'assembly-preview.step')) report={'revision':2,'nominal_console_mm':{'height':390,'width':104,'depth':260},'platform_mm':[240,320,100], 'physical_fit_tested':False,'load_tested':False,'console_surface_geometry_verified':False,'parts':parts} (O/'validation.json').write_text(json.dumps(report,indent=2)+'\n') print(json.dumps(report,indent=2)) # Actual CAD preview, without an invented console surface. import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.art3d import Poly3DCollection fig=plt.figure(figsize=(12,8),facecolor='#141313') ax=fig.add_subplot(111,projection='3d',facecolor='#141313') all_triangles=[]; all_colors=[] import numpy as np from matplotlib.colors import to_rgb for i,solid in enumerate(assembled): vertices,faces=solid.tessellate(0.3) xyz=[v.toTuple() for v in vertices] triangles=[[xyz[j] for j in f] for f in faces] color='#9c6040' if i<2 else '#b83f32' if i>=8 else '#55565b' for tri in triangles: a,b,c=np.array(tri) n=np.cross(b-a,c-a); n=n/max(np.linalg.norm(n),1e-12) light=np.array([-0.5,-0.5,1.0]); light/=np.linalg.norm(light) shade=0.55+0.45*abs(float(np.dot(n,light))) all_triangles.append(tri); all_colors.append(np.array(to_rgb(color))*shade) ax.add_collection3d(Poly3DCollection(all_triangles,facecolors=all_colors,edgecolor='none',zsort='average')) ax.set(xlim=(-140,140),ylim=(-180,180),zlim=(0,180)) ax.set_box_aspect((280,360,180)); ax.view_init(elev=27,azim=-58); ax.set_axis_off() fig.subplots_adjust(left=0,right=1,bottom=0,top=1) fig.savefig(O/'preview.png',dpi=150,facecolor=fig.get_facecolor())