MCPcopy
hub / github.com/CadQuery/cadquery / testEnclosure

Method testEnclosure

tests/test_cadquery.py:3270–3400  ·  view source on GitHub ↗

Builds an electronics enclosure Original FreeCAD script: 81 source statements ,not including variables This script: 34

(self)

Source from the content-addressed store, hash-verified

3268 self.saveModel(s3)
3269
3270 def testEnclosure(self):
3271 """
3272 Builds an electronics enclosure
3273 Original FreeCAD script: 81 source statements ,not including variables
3274 This script: 34
3275 """
3276
3277 # parameter definitions
3278 p_outerWidth = 100.0 # Outer width of box enclosure
3279 p_outerLength = 150.0 # Outer length of box enclosure
3280 p_outerHeight = 50.0 # Outer height of box enclosure
3281
3282 p_thickness = 3.0 # Thickness of the box walls
3283 p_sideRadius = 10.0 # Radius for the curves around the sides of the bo
3284 # Radius for the curves on the top and bottom edges of the box
3285 p_topAndBottomRadius = 2.0
3286
3287 # How far in from the edges the screwposts should be place.
3288 p_screwpostInset = 12.0
3289 # Inner Diameter of the screwpost holes, should be roughly screw diameter not including threads
3290 p_screwpostID = 4.0
3291 # Outer Diameter of the screwposts.\nDetermines overall thickness of the posts
3292 p_screwpostOD = 10.0
3293
3294 p_boreDiameter = 8.0 # Diameter of the counterbore hole, if any
3295 p_boreDepth = 1.0 # Depth of the counterbore hole, if
3296 # Outer diameter of countersink. Should roughly match the outer diameter of the screw head
3297 p_countersinkDiameter = 0.0
3298 # Countersink angle (complete angle between opposite sides, not from center to one side)
3299 p_countersinkAngle = 90.0
3300 # Whether to place the lid with the top facing down or not.
3301 p_flipLid = True
3302 # Height of lip on the underside of the lid.\nSits inside the box body for a snug fit.
3303 p_lipHeight = 1.0
3304
3305 # outer shell
3306 oshell = (
3307 Workplane("XY")
3308 .rect(p_outerWidth, p_outerLength)
3309 .extrude(p_outerHeight + p_lipHeight)
3310 )
3311
3312 # weird geometry happens if we make the fillets in the wrong order
3313 if p_sideRadius > p_topAndBottomRadius:
3314 oshell = (
3315 oshell.edges("|Z")
3316 .fillet(p_sideRadius)
3317 .edges("#Z")
3318 .fillet(p_topAndBottomRadius)
3319 )
3320 else:
3321 oshell = (
3322 oshell.edges("#Z")
3323 .fillet(p_topAndBottomRadius)
3324 .edges("|Z")
3325 .fillet(p_sideRadius)
3326 )
3327

Callers

nothing calls this directly

Calls 15

saveModelMethod · 0.95
WorkplaneClass · 0.85
extrudeMethod · 0.80
workplaneMethod · 0.80
allMethod · 0.80
cboreHoleMethod · 0.80
cskHoleMethod · 0.80
holeMethod · 0.80
rotateAboutCenterMethod · 0.80
unionMethod · 0.80
rectMethod · 0.45
filletMethod · 0.45

Tested by

no test coverage detected