Skip to main content

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

  1. FOLD file documentation
  2. Toshikazu Kawasaki's Theorem on flat-foldability
  3. Jun Maekawa's Theorem on mountain-valley assignments
  4. My Graph Theory notes

Authors

  • Coleman Lai

Acknowledgments

  • The FOLD file project contributors
  • Claude AI by Anthropic (for debugging/generation of some code)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

box_pleating-1.1.0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

box_pleating-1.1.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file box_pleating-1.1.0.tar.gz.

File metadata

  • Download URL: box_pleating-1.1.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for box_pleating-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d8f1fd60594a3cfbc08641c35bbce8588cd2753cb7f5fd1b73b2d0d9014a47a0
MD5 087fb0a8ff04375a8c89fb1f1e379c0a
BLAKE2b-256 42dd9d5f723b3f211ff235e1c91729b7eba0235b62145bd14f6912171fde61f6

See more details on using hashes here.

File details

Details for the file box_pleating-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: box_pleating-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for box_pleating-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfe97ea869b01a962f630ba83945aa404613bc2f04e688254156e9a03f2ef1e0
MD5 f2087db69d7811b27241799ed75cf2cc
BLAKE2b-256 05cbcd97e809526df1951e43996441ff361ef0abe4ca2c841c7e217d6277305c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page