A parametric IP66-rated enclosure generator for 3D printing, built with CadQuery. This package allows you to easily create customized enclosures with gaskets and various screw mounting options.
All components (box, lid, and gasket) can be exported as STEP files for compatibility with any CAD software and 3D printing workflow.
- Fully parametric enclosure generation
- IP66-rated design with gasket
- Multiple screw mounting options:
- Inside or outside box mounting
- Wood screw or machine screw support with countersunk head
- Configurable corner and middle screw positions
- Mounting holders for attaching the enclosure
- Automatic generation of:
- Main enclosure box
- Matching lid
- Gasket for water-tight seal
Requires python 3.10 or higher.
pip install cq-enclosureSee the examples directory for complete usage examples.
box, lid, gasket = Enclosure(
box_inner_width=31.0,
box_inner_length=71.0,
box_inner_height=31.0,
screw_location=ScrewLocation.INSIDE_BOX,
middle_length_screws=True,
).build()box, lid, gasket = Enclosure(
box_inner_width=31.0,
box_inner_length=71.0,
box_inner_height=31.0,
screw_location=ScrewLocation.INSIDE_BOX,
middle_length_screws=True,
screw_type=ScrewType.WITH_SQUARE_NUT,
).build()box, lid, gasket = Enclosure(
box_inner_width=31.0,
box_inner_length=71.0,
box_inner_height=31.0,
screw_location=ScrewLocation.OUTSIDE_BOX,
middle_width_screws=True,
corner_screws=False,
screw_type=ScrewType.WITH_SQUARE_NUT,
).build()box, lid, gasket = Enclosure(
box_inner_width=31.0,
box_inner_length=71.0,
box_inner_height=31.0,
screw_location=ScrewLocation.OUTSIDE_BOX,
middle_length_screws=True,
corner_screws=False,
screw_type=ScrewType.WITH_SQUARE_NUT,
).build()box, lid, gasket = Enclosure(
box_inner_width=50.0,
box_inner_length=50.0,
box_inner_height=40.0,
screw_location=ScrewLocation.OUTSIDE_BOX,
corner_screws=False,
middle_width_screws=True,
middle_length_screws=True,
screw_type=ScrewType.WOOD_SCREW,
).build()box, lid, gasket = Enclosure(
box_inner_width=50.0,
box_inner_length=50.0,
box_inner_height=40.0,
screw_location=ScrewLocation.OUTSIDE_BOX,
corner_screws=False,
middle_width_screws=True,
middle_length_screws=True,
screw_type=ScrewType.WOOD_SCREW,
mount_holders=False,
).build()The Enclosure class accepts the following parameters:
box_inner_width: Internal width (X) of the enclosurebox_inner_length: Internal length (Y) of the enclosurebox_inner_height: Internal height (Z) of the enclosureactual_inner_width: Whether to include screw cylinder dimensions in box_inner_width when using inside box screws (default: True)actual_inner_length: Whether to include screw cylinder dimensions in box_inner_length when using inside box screws (default: True)
cut_top: Height at which the box splits into lid and base (default: 5.0mm)
screw_location: Location of mounting screws (ScrewLocation.INSIDE_BOXorScrewLocation.OUTSIDE_BOX, default: OUTSIDE_BOX)screw_type: Type of screws to use (ScrewType.WOOD_SCREWorScrewType.WITH_SQUARE_NUT, default: WOOD_SCREW)screw_hole_diameter: Diameter of the screw holes (default: 3.3mm including tolerance)screw_head_diameter: Diameter of the screw head (default: 6.0mm)screw_total_length: Total length of the screws (default: 16.0mm)corner_screws: Enable/disable corner mounting points (default: True)middle_length_screws: Enable/disable middle mounting points on length sides (default: False)middle_width_screws: Enable/disable middle mounting points on width sides (default: False)
square_nut_width: Width of square nuts (default: 5.5mm)square_nut_height: Height of square nuts (default: 1.8mm)nut_wa_type: Nut printing workaround type (NutPrintingWA.CUT_RECT_SPACESorNutPrintingWA.ADD_CEILING, default: ADD_CEILING)
gasket_height: Height of the gasket (default: 1.6mm)gasket_width: Width of the gasket (default: 1.2mm)gasket_spacing: Spacing around the gasket (default: 0.15mm)gasket_compression: Compression factor for the gasket (default: 0.2mm)
mount_holders: Enable/disable mounting holders (default: True)mount_holder_length: Length of mounting holders (default: 15.0mm)mount_holders_screw_hole_diameter: Diameter of mount holder screw holes (default: 5.0mm)mount_holders_head_screw_diameter: Diameter of mount holder screw heads (default: 9.0mm)mount_holders_fillet: Enable/disable fillets on mount holders (default: True)
layer_height: Layer height for 3D printing, used for square nut printing trick (default: 0.28mm)
fillet_bottom: Enable/disable bottom fillets (default: True)fillet_top: Enable/disable top fillets (default: True)
To set up a development environment:
- Clone the repository
- Install astral uv package manager.
- Create and initialize a virtual environment:
uv sync






