User: 
Create a lofted section between a rectangle and a circular section.
1.  Establishes a workplane that an object can be built on.
1a. Uses the named plane orientation "front" to define the workplane, meaning
    that the positive Z direction is "up", and the negative Z direction
     is "down".
2.  Creates a plain box to base future geometry on with the box() function.
3.  Selects the top-most Z face of the box.
4.  Draws a 2D circle at the center of the the top-most face of the box.
5.  Creates a workplane 3 mm above the face the circle was drawn on.
6.  Draws a 2D circle on the new, offset workplane.
7.  Creates a loft between the circle and the rectangle.

System:
import cadquery as cq
result = (
    cq.Workplane("front")
    .box(4.0, 4.0, 0.25)
    .faces(">Z")
    .circle(1.5)
    .workplane(offset=3.0)
    .rect(0.75, 0.5)
    .loft(combine=True)
)
result.val().exportStl("Generated.stl")


######### END #########
User: 
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.

System:
import cadquery as cq
# These can be modified rather than hardcoding values for each dimension.
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
result = (
    cq.Workplane("XY")
    .box(length, height, thickness)
    .faces(">Z")
    .workplane()
    .hole(center_hole_dia)
)
result.val().exportStl("Generated.stl")

######### END #########
User: 
1.  Establishes a workplane to create the spline on to extrude.
 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".
 The points that the spline will pass through
2.  Generate our plate with the spline feature and make sure it is a
     closed entity
3.  Extrude to turn the wire into a plate

System:
import cadquery as cq

s = cq.Workplane("XY")
sPnts = [
    (2.75, 1.5),
    (2.5, 1.75),
    (2.0, 1.5),
    (1.5, 1.0),
    (1.0, 1.25),
    (0.5, 1.0),
    (0, 1.0),
]

r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(sPnts, includeCurrent=True).close()
result = r.extrude(0.5)
result.val().exportStl("Generated.stl")

######### END #########
User: 
We generate half of the I-beam outline and then mirror it to create the full I-beam.
1.  Establishes a workplane that an object can be built on.
1a. Uses the named plane orientation "front" to define the workplane, meaning
    that the positive Z direction is "up", and the negative Z direction
    is "down".
2.  moveTo() is used to move the first point from the origin (0, 0) to
    (0, 10.0), with 10.0 being half the height (H/2.0). If this is not done
    the first line will start from the origin, creating an extra segment that
    will cause the extrude to have an invalid shape.
3.  The polyline function takes a list of points and generates the lines
    through all the points at once.
3.  Only half of the I-beam profile has been drawn so far. That half is
    mirrored around the Y-axis to create the complete I-beam profile.
4.  The I-beam profile is extruded to the final length of the beam.

System:
import cadquery as cq

(L, H, W, t) = (100.0, 20.0, 20.0, 1.0)
pts = [
    (0, H / 2.0),
    (W / 2.0, H / 2.0),
    (W / 2.0, (H / 2.0 - t)),
    (t / 2.0, (H / 2.0 - t)),
    (t / 2.0, (t - H / 2.0)),
    (W / 2.0, (t - H / 2.0)),
    (W / 2.0, H / -2.0),
    (0, H / -2.0),
]


result = cq.Workplane("front").polyline(pts).mirrorY().extrude(L)
result.val().exportStl("Generated.stl")

######### END #########
User: 
1.  Establishes a workplane that an object can be built on.
1a. Uses the named plane orientation "front" to define the workplane, meaning
    that the positive Z direction is "up", and the negative Z direction is "down".
2.  A horizontal line is drawn on the workplane with the hLine function.
2a. 1.0 is the distance, not coordinate. hLineTo allows using xCoordinate
    not distance.
3.  Draw a series of vertical and horizontal lines with the vLine and hLine
    functions.
4.  Mirror the geometry about the Y axis and extrude it into a 3D object.

System:
import cadquery as cq
r = cq.Workplane("front").hLine(1.0)


r = r.vLine(0.5).hLine(-0.25).vLine(-0.25).hLineTo(0.0)

result = r.mirrorY().extrude(0.25)

result.val().exportStl("Generated.stl")
######### END #########
User:
  Write Python code using CADQuery to create an extruded rectangle with two precisely shaped rectangular holes. To create the object, start with a sketch of a thin rectangle whose width is approximately 10-15 times its height. Slightly extrude this rectangle. Then, on top of this extruded shape, sketch two symmetric rectangles and extrude them negatively to create two rectangular holes in the original extruded shape. These rectangular holes should be slightly less than half the size of the original rectangle. Position them so that they don't touch each other or any edge of the original rectangle. 