Provides a Python script to generate custom .step files for 3D-printable battery cell holders. You can easily define the dimensions, cell size, spacing, and other features.
To generate a cell holder, run the script from your terminal using the following command structure.
python3 layout_step.py <x_dim> <y_dim> <spacing> <cell_size> <cover_thickness> <rounded_corners> <bms_holes> <ledge_width> [fillet_bms]Before running the script, it is recommended to create a Python virtual environment and install the required dependencies.
- Create a venv:
python3 -m venv venv
- Activate the venv:
Linux/macOS:
source venv/bin/activateWindows (PowerShell):
.\venv\Scripts\Activate.ps1- Install the dependencies:
pip install -r requirements.txtNote: If your Python version is above 3.12 and the installed cadquery version is below 2.5.2, the standard requirements.txt installation may fail. In that case, install Python 3.11, create the venv through that version.
The script accepts the following arguments in order:
| Parameter | Description | Data Type |
|---|---|---|
x_dim, y_dim |
Total allowed width & length in mm. | float |
spacing |
The minimum wall thickness between cell holes. (e.g., 0.43 for a 0.4mm nozzle). |
float |
cell_size |
The diameter of your battery cell, including any desired tolerance (e.g., 21.4-21.7 for a 21700 cell). |
float |
cover_thickness |
The thickness of the ledge_width. (0.2-0.4 is normal) |
float |
rounded_corners |
Rounded external corners on the holder. | true / false |
bms_holes |
Adds mounting holes for balancing. | true / false |
ledge_width |
Cover ledge in mm, 3.75 to mimic fishpaper. |
float |
fillet_bms |
(Optional, causes segmentation fault <18.5 cells) Adds a fillet to the balancing holes. | true / false |
Here is an example command for generating a holder for 21700 cells, optimized for printing with a 0.4mm nozzle.
python3 layout_step.py 100 100 0.43 21.5 0.4 true true 3.75 true