Box pleating crease pattern creation and flat-foldability with FOLD file import/export
Project description
box-pleating: GitHub, PyPI
A Python package for creating, analyzing, and validating box-pleating origami patterns. Provides tools for working with box-pleating patterns including FOLD format conversion and flat-foldability validation.
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
- 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file box_pleating-1.0.1.tar.gz.
File metadata
- Download URL: box_pleating-1.0.1.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
182ebf2280c5d608591b6eb0f6289db716a9daccbf1c932747eaa88668a8e978
|
|
| MD5 |
777b201491bab57cd8176420d0490cd5
|
|
| BLAKE2b-256 |
8f3d69eff165a51897e2c4cc1205e0acdbb8254b7db5e2a1b6c006517a5e16a8
|
File details
Details for the file box_pleating-1.0.1-py3-none-any.whl.
File metadata
- Download URL: box_pleating-1.0.1-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16a151207305ce49cfc2b6c097376a3c08c42fec6e9054523b4df492a71bfe20
|
|
| MD5 |
d59ab7fa491c974f1624a2f5c05125ce
|
|
| BLAKE2b-256 |
a9f619785606e08747ca5a13e06ad8a2c3c7f741c19b6c37a4d8ff0b063c3b64
|