2018-12-29 18:44:08 -05:00
|
|
|
import cadquery as cq
|
|
|
|
|
|
|
|
# These can be modified rather than hardcoding values for each dimension.
|
2020-01-20 20:52:12 +01:00
|
|
|
length = 80.0 # Length of the block
|
|
|
|
height = 60.0 # Height of the block
|
|
|
|
thickness = 10.0 # Thickness of the block
|
|
|
|
center_hole_dia = 22.0 # Diameter of center hole in block
|
2018-12-29 18:44:08 -05:00
|
|
|
|
|
|
|
# Create a block based on the dimensions above and add a 22mm center hole.
|
|
|
|
# 1. Establishes a workplane that an object can be built on.
|
|
|
|
# 1a. Uses the X and Y origins to define the workplane, meaning that the
|
|
|
|
# positive Z direction is "up", and the negative Z direction is "down".
|
|
|
|
# 2. The highest (max) Z face is selected and a new workplane is created on it.
|
|
|
|
# 3. The new workplane is used to drill a hole through the block.
|
|
|
|
# 3a. The hole is automatically centered in the workplane.
|
2020-01-20 20:52:12 +01:00
|
|
|
result = (
|
|
|
|
cq.Workplane("XY")
|
|
|
|
.box(length, height, thickness)
|
|
|
|
.faces(">Z")
|
|
|
|
.workplane()
|
|
|
|
.hole(center_hole_dia)
|
|
|
|
)
|
2018-12-29 18:44:08 -05:00
|
|
|
|
|
|
|
# Displays the result of this script
|
|
|
|
show_object(result)
|