<s> import cadquery <EOL> import Part <EOL> p_outerWidth = <NUM_LIT> <EOL> p_outerLength = <NUM_LIT> <EOL> p_outerHeight = <NUM_LIT> <EOL> p_thickness = <NUM_LIT> <EOL> p_sideRadius = <NUM_LIT> <EOL> p_topAndBottomRadius = <NUM_LIT> <EOL> p_screwpostInset = <NUM_LIT> <EOL> p_screwpostID = <NUM_LIT> <EOL> p_screwpostOD = <NUM_LIT> <EOL> p_boreDiameter = <NUM_LIT> <EOL> p_boreDepth = <NUM_LIT:1.0> <EOL> p_countersinkDiameter = <NUM_LIT:0.0> <EOL> p_countersinkAngle = <NUM_LIT> <EOL> p_flipLid = True <EOL> p_lipHeight = <NUM_LIT:1.0> <EOL> oshell = cadquery . Workplane ( "<STR_LIT>" ) . rect ( p_outerWidth , p_outerLength ) . extrude ( p_outerHeight + p_lipHeight ) <EOL> if p_sideRadius > p_topAndBottomRadius : <EOL> oshell . edges ( "<STR_LIT>" ) . fillet ( p_sideRadius ) <EOL> oshell . edges ( "<STR_LIT>" ) . fillet ( p_topAndBottomRadius ) <EOL> else : <EOL> oshell . edges ( "<STR_LIT>" ) . fillet ( p_topAndBottomRadius ) <EOL> oshell . edges ( "<STR_LIT>" ) . fillet ( p_sideRadius ) <EOL> ishell = oshell . faces ( "<STR_LIT>" ) . workplane ( p_thickness , True ) . rect ( ( p_outerWidth - <NUM_LIT> * p_thickness ) , ( p_outerLength - <NUM_LIT> * p_thickness ) ) . extrude ( ( p_outerHeight - <NUM_LIT> * p_thickness ) , False ) <EOL> ishell . edges ( "<STR_LIT>" ) . fillet ( p_sideRadius - p_thickness ) <EOL> box = oshell . cut ( ishell ) <EOL> POSTWIDTH = ( p_outerWidth - <NUM_LIT> * p_screwpostInset ) <EOL> POSTLENGTH = ( p_outerLength - <NUM_LIT> * p_screwpostInset ) <EOL> postCenters = box . faces ( "<STR_LIT>" ) . workplane ( - p_thickness ) . rect ( POSTWIDTH , POSTLENGTH , forConstruction = True ) . vertices ( ) <EOL> for v in postCenters . all ( ) : <EOL> v . circle ( p_screwpostOD / <NUM_LIT> ) . circle ( p_screwpostID / <NUM_LIT> ) . extrude ( ( - <NUM_LIT:1.0> ) * ( ( p_outerHeight + p_lipHeight ) - ( <NUM_LIT> * p_thickness ) ) , True ) <EOL> ( lid , bottom ) = box . faces ( "<STR_LIT>" ) . workplane ( - p_thickness - p_lipHeight ) . split ( keepTop = True , keepBottom = True ) . all ( ) <EOL> lowerLid = lid . translate ( ( <NUM_LIT:0> , <NUM_LIT:0> , - p_lipHeight ) ) <EOL> cutlip = lowerLid . cut ( bottom ) . translate ( ( p_outerWidth + p_thickness , <NUM_LIT:0> , p_thickness - p_outerHeight + p_lipHeight ) ) <EOL> topOfLidCenters = cutlip . faces ( "<STR_LIT>" ) . workplane ( ) . rect ( POSTWIDTH , POSTLENGTH , forConstruction = True ) . vertices ( ) <EOL> if p_boreDiameter > <NUM_LIT:0> and p_boreDepth > <NUM_LIT:0> : <EOL> topOfLid = topOfLidCenters . cboreHole ( p_screwpostID , p_boreDiameter , p_boreDepth , ( <NUM_LIT> ) * p_thickness ) <EOL> elif p_countersinkDiameter > <NUM_LIT:0> and p_countersinkAngle > <NUM_LIT:0> : <EOL> topOfLid = topOfLidCenters . cskHole ( p_screwpostID , p_countersinkDiameter , p_countersinkAngle , ( <NUM_LIT> ) * p_thickness ) <EOL> else : <EOL> topOfLid = topOfLidCenters . hole ( p_screwpostID , <NUM_LIT> * p_thickness ) <EOL> if p_flipLid : <EOL> topOfLid . rotateAboutCenter ( ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , <NUM_LIT> ) <EOL> result = topOfLid . combineSolids ( bottom ) <EOL> Part . show ( result . toFreecad ( ) ) </s>
