Box Pleating
A Python library for creating and validating box-pleating origami patterns.
Installation
pip install box-pleating
Quick Start
from box_pleating import BoxPleatingPattern, Point, CreaseType
from box_pleating.fold import FoldConverter
# Create a new pattern with a 10x10 grid
pattern = BoxPleatingPattern(grid_size=10)
# Add creases
pattern.add_crease(
Point(0, 0),
Point(5, 5),
CreaseType.MOUNTAIN
)
# Check if pattern is valid and flat-foldable
is_valid, report = pattern.is_valid_pattern()
# Convert to FOLD format
converter = FoldConverter()
fold_data = converter.to_fold(pattern)
Features
Box-Pleating Pattern Creation
- Create patterns on a customizable grid
- Add mountain, valley and border folds
- Automatic intersection and overlap handling
- Grid-based validation ensuring 45° and 90° angles (No Pythagorean Stretches, unfortunately)
Pattern Validation
- Local flat-foldability checking using:
- Kawasaki's theorem (alternating angles sum to 180°)
- Maekawa's theorem (mountain/valley crease difference is 2)
- Crease intersection detection
- Grid alignment verification, kind of
FOLD Format Support
- Import from FOLD format
- Export to FOLD format
- Automatic grid size optimization, kind of
- Redundant vertex removal
Coming Soon (Maybe)
- Crease removal/changing
Detailed Usage
Creating a Pattern
from box_pleating import BoxPleatingPattern, Point, CreaseType
# Create a pattern with a 10x10 grid
pattern = BoxPleatingPattern(grid_size=10)
# Add a mountain fold
pattern.add_crease(
Point(0, 0), # Start point
Point(5, 5), # End point
CreaseType.MOUNTAIN
)
# Add a valley fold
pattern.add_crease(
Point(5, 5),
Point(10, 5),
CreaseType.VALLEY
)
Converting FOLD Format
from box_pleating.fold import FoldConverter
converter = FoldConverter()
# Load from FOLD file
pattern = converter.load_fold("input.fold")
# Save to FOLD file
converter.save_fold(pattern, "output.fold")
Validating Patterns
# Check flat-foldability
is_foldable, violations = pattern.is_flat_foldable()
if not is_foldable:
print("Violations found:")
for violation in violations:
print(f"Vertex at ({violation['vertex']['x']}, {violation['vertex']['y']})")
print(f"Maekawa satisfied: {violation['maekawa_satisfied']}")
print(f"Kawasaki satisfied: {violation['kawasaki_satisfied']}")
# Check overall pattern validity
is_valid, report = pattern.is_valid_pattern()
Pattern Cleanup
# Remove redundant vertices (vertices where parallel creases of the same type meet)
pattern.remove_redundant_vertices()
Contributing
Contributions are welcome.
License
This project is licensed under the MIT License - see the LICENSE file for details.
References
- FOLD file documentation
- Toshikazu Kawasaki's Theorem on flat-foldability
- Jun Maekawa's Theorem on mountain-valley assignments
- My Graph Theory notes
Authors
- Coleman Lai
Acknowledgments
- The FOLD file project contributors
- Claude AI by Anthropic (for debugging/generation of some code)
Release files for box-pleating 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| box_pleating-1.1.0.tar.gz | 24.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| box_pleating-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.9 kB
Release files / box_pleating-1.1.0.tar.gz
| Download URL | box_pleating-1.1.0.tar.gz |
|---|---|
| Size | 24.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8f1fd60594a3cfbc08641c35bbce8588cd2753cb7f5fd1b73b2d0d9014a47a0
|
|
BLAKE2b-256 checksum How to use checksums |
42dd9d5f723b3f211ff235e1c91729b7eba0235b62145bd14f6912171fde61f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / box_pleating-1.1.0-py3-none-any.whl
| Download URL | box_pleating-1.1.0-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dfe97ea869b01a962f630ba83945aa404613bc2f04e688254156e9a03f2ef1e0
|
|
BLAKE2b-256 checksum How to use checksums |
05cbcd97e809526df1951e43996441ff361ef0abe4ca2c841c7e217d6277305c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|