A KiCad Python extension for visualizing folded/bent flex PCBs in an interactive 3D window.
Demo: youtube
KiCad does not natively support flex PCB bend visualization in its 3D viewer. This plugin fills that gap by:
- Providing a marker system to define fold lines directly in the PCB layout
- Parsing the board geometry from
.kicad_pcbfiles (no STEP export needed) - Applying mathematical bend transformations
- Rendering the folded PCB in a separate interactive 3D window
- Direct KiCad integration: Two action buttons in PCB Editor toolbar
- Visual fold markers: Define bends using selection-based placement
- Real-time preview: Adjust bend angles with interactive controls
- Performance modes: From fast outline-only to full component rendering
- 3D model support: Load and display component 3D models (WRL/STEP)
- Stiffener regions: Define and visualize stiffener areas
- STEP export: Export bent geometry to STEP format for CAD tools
- Configurable marker layer: Use any User layer for fold markers
- Design validation: Warnings for bend radius, stiffener conflicts, components in bend zones
Selection-based workflow:
┌─────────────────────────────────────────────────────────────┐
│ 1. Draw a graphic line on User layer where you want the │
│ fold (the line defines fold position and direction) │
│ │
│ 2. Select the line in KiCad │
│ │
│ 3. Click "Create Fold" button │
│ └─► Dialog opens with angle and zone width inputs │
│ └─► Creates two parallel dotted lines + dimension │
│ └─► Original line is replaced with fold marker │
└─────────────────────────────────────────────────────────────┘
Alternative: If no line is selected, a dialog prompts for manual coordinate entry.
Opens the 3D visualization window with:
- Folded PCB rendering
- Angle adjustment sliders (per fold)
- Display mode checkboxes (outline/traces/pads/components)
- Export options
┌─────────────────────────────────────────────────────────────┐
│ KiCad PCB Editor │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Toolbar: [Create Fold] [Open Viewer] │ │
│ └─────────────────────────────────────────────────────┘ │
│ ┌───────────────────────────────────────────────────────┐ │
│ │ Board with fold markers on User layer (configurable) │ │
│ └───────────────────────────────────────────────────────┘ │
└─────────────────────┬───────────────────────────────────────┘
│ "Open Viewer" clicked
▼
┌─────────────────────────────────────────────────────────────┐
│ Flex Viewer Window │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────┬──────────────────────┐ │
│ │ │ Controls: │ │
│ │ │ ┌──────────────────┐ │ │
│ │ 3D Viewport │ │ Fold 1: [====●==]│ │ │
│ │ (PyVista/vispy) │ │ Fold 2: [==●====]│ │ │
│ │ │ └──────────────────┘ │ │
│ │ │ Display: │ │
│ │ │ ☑ Outline │ │
│ │ │ ☑ Traces │ │
│ │ │ ☐ Pads │ │
│ │ │ ☐ Components │ │
│ │ │ │ │
│ │ │ [Refresh] [Export] │ │
│ └─────────────────────────────────┴──────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Fold markers are placed on a User layer (configurable, default: User.1) and consist of three elements:
┆ ┆
┆ ┆
═══════╪════════╪═══════════════ PCB Edge
┆ ┆
┆ +90° ┆ ← Dimension (positive = fold toward viewer)
┆ ┆
═══════╪════════╪═══════════════
┆ ┆
Line A Line B
(dotted) (dotted)
| Element | Description |
|---|---|
| Line A | Dotted line on User.1 - start of bend zone |
| Line B | Dotted line on User.1 - end of bend zone |
| Dimension | Angle in degrees between the lines |
- Angle: From dimension text (signed: +up/-down from PCB plane)
- Bend radius: Derived from line spacing:
R = line_distance / angle_in_radians - Fold axis: Perpendicular to line A-B direction
- Order: Not required - folds are independent based on position
| Mode | Elements Rendered | Performance | Use Case |
|---|---|---|---|
| Outline | Board edge only | Very fast | Real-time angle adjustment |
| Traces | Outline + copper traces | Fast | Design verification |
| Pads | Above + pads | Medium | Component placement check |
| Components | Above + component bounding boxes | Medium | Collision detection |
| Full 3D | Above + 3D models | Slow | Final visualization |
- Download the latest release: flexviz-1.0.0.zip
- Open KiCad and go to Plugin and Content Manager (PCM)
- Click Install from File... at the bottom
- Select the downloaded
flexviz-1.0.0.zip - Restart KiCad
git clone https://github.com/Aightech/flexviz.git
cd flexviz
./install.shThe install script will:
- Auto-detect your KiCad version (7.0, 8.0, 9.0)
- Create a symlink for development (or copy for distribution)
- Show you where the plugin was installed
Download the latest release ZIP and extract to your KiCad plugins directory:
# For KiCad 9.x
unzip flexviz-*.zip -d ~/.local/share/kicad/9.0/3rdparty/plugins/
# For KiCad 8.x
unzip flexviz-*.zip -d ~/.local/share/kicad/8.0/3rdparty/plugins/
# For KiCad 7.x
unzip flexviz-*.zip -d ~/.local/share/kicad/7.0/scripting/plugins/- Restart KiCad PCB Editor
- Go to Tools → External Plugins
- You should see:
- Flex Viewer - Test (verifies plugin works)
- Create Fold
- Open Fold Viewer
pip install vispy numpy- Create folds: Click "Create Fold" button → click point A → click point B → set angle
- Repeat for additional folds as needed
- Visualize: Click "Open Viewer" to see the folded PCB in 3D
- Adjust: Use sliders to fine-tune angles, checkboxes for display options
- Export: Save bent geometry as OBJ/STL if needed
flexviz/
├── plugins/
│ └── com_github_aightech_flexviz/ # KiCad plugin package
│ ├── __init__.py # Plugin registration
│ ├── plugin.py # KiCad ActionPlugin classes
│ ├── kicad_parser.py # .kicad_pcb file parser
│ ├── geometry.py # Board geometry extraction
│ ├── markers.py # Fold marker detection
│ ├── bend_transform.py # 3D bend transformation
│ ├── mesh.py # Triangle mesh generation
│ ├── viewer.py # wxPython + OpenGL viewer
│ ├── step_export.py # STEP CAD export
│ └── resources/ # Button icons
├── tests/ # Unit tests
│ ├── test_kicad_parser.py
│ ├── test_markers.py
│ └── test_data/ # Test PCB files
├── docs/ # Documentation
├── install.sh # Installation script
└── README.md
The bend transformation maps points from flat PCB space to bent 3D space:
For a fold at position P, with axis direction A, radius R, and angle θ:
1. Points before fold zone: unchanged (z = 0)
2. Points in fold zone (0 < d < arc_length):
- Map to cylindrical coordinates
- x' = x
- y' = R × sin(d / R)
- z' = R × (1 - cos(d / R))
3. Points after fold zone:
- Apply rotation matrix around fold axis
- Translate to end of arc
- Components are displayed as bounding boxes or reference points (full 3D model bending is computationally expensive)
- Single-sided view (no layer stackup simulation)
- Bend radius must be larger than board thickness for realistic results
- Fold animation / stepped preview
-
Export to STEP(completed via build123d) - Collision detection between folded sections
- Integration with DRC for bend radius rules
- Support for rigid-flex zone definitions
- Edit existing fold markers (move, change angle)
- Delete fold marker tool
- Silkscreen layer display
- Copper zone fill visualization
MIT License
Contributions welcome! See CONTRIBUTING.md for guidelines.