_images/cq_title_image.png

If you’ve ever wondered if there is a better alternative to doing mechanical CAD with proprietary software products, CadQuery and this package - cq_warehouse - and similar packages like cq_gears might be what you’ve been looking for. CadQuery augments the Python programming language (the second most widely used programming language) with powerful capabilities enabling a wide variety of mechanical designs to be created in S/W with the same techniques that enable most of today’s technology.

cq_warehouse augments CadQuery with parametric parts - generated on demand - and extensions to the core CadQuery capabilities. The resulting parts can be used within your projects or saved to a CAD file in STEP or STL format (among others) for use in a wide variety of CAD, CAM, or analytical systems.

As an example, consider the design of a simple bearing pillow block:

import cadquery as cq
from cq_warehouse.fastener import SocketHeadCapScrew
from cq_warehouse.bearing import SingleRowDeepGrooveBallBearing
import cq_warehouse.extensions

height = 60.0
width = 80.0
thickness = 10.0
padding = 12.0

# make the bearing
bearing = SingleRowDeepGrooveBallBearing(size="M8-22-7", bearing_type="SKT")
# make the screw
screw = SocketHeadCapScrew(
    size="M2-0.4", fastener_type="iso4762", length=16, simple=False
)
# make the assembly
pillow_block = cq.Assembly(None, name="pillow_block")
# make the base
base = (
    cq.Workplane("XY")
    .box(height, width, thickness)
    .faces(">Z")
    .workplane()
    .pressFitHole(bearing=bearing, baseAssembly=pillow_block)
    .faces(">Z")
    .workplane()
    .rect(height - padding, width - padding, forConstruction=True)
    .vertices()
    .clearanceHole(fastener=screw, baseAssembly=pillow_block)
    .edges("|Z")
    .fillet(2.0)
)
pillow_block.add(base, name="base", color=cq.Color(162 / 255, 138 / 255, 255 / 255))
print(pillow_block.fastenerQuantities())

# Render the assembly
if "show_object" in locals():
    show_object(pillow_block)

Which results in:

pillow_block

With just a few lines of code a parametric part can be created that can be easily reviewed and version controlled (with tools like git and github). Documentation can be autogenerated - as with much of the documentation that you’re reading now - from the source code of your designs. Parts can be validated automatically with comprehensive test suites to ensure flaws don’t get introduced during the lifecycle of a part. The benefits of a full S/W development pipeline are too numerous to mention here but also consider that all of these tools are OpenSource and free to use - no more licenses - and modifiable if required. Take control of your CAD development tools.

Table Of Contents

Indices and tables