Skip to content

Python script for generating Miura fold crease patterns in SVG—auto-fits to paper size with customizable compactness and angles. Print, score, fold: no math needed.

License

Notifications You must be signed in to change notification settings

5ynthaire/5YN-MiuraFoldPatternGen-PY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Script: Miura Fold Pattern SVG Generator

Standalone Binary (No Python Required)

Latest Release

Purpose

This Python script generates a Miura-ori crease pattern in SVG format for printing or further editing. It automatically fits the pattern to user-specified paper dimensions and a compactness factor, handling rhombus sizing and angles without manual calculations.

What is Miura-ori?

If you're new: Miura-ori is a rigid origami pattern of interlocking parallelograms that folds a flat sheet (like paper or solar panels) into a compact accordion. Invented by Japanese engineer Kōryō Miura in the 1970s, it's famous for efficient packing—think deployable space tech or map-folding hacks. See Wikipedia.

Output Example

sample

Note: Post-processed for presentation

Requirements

Python Script

  • Python 3.6+

Windows Binary

  • Windows

Commandline Switches

  • --compact: Compactness factor along the shorter paper edge. Default: 7 (folds to 1/7th of the shorter edge).
  • Dimensions: --mm <h>x<w>, --in <h>x<w>, or --px <h>x<w> (default: 816x1056 px for letter portrait).
  • --output: Specify output file name. Default miura_fold.svg.
  • --folds-dotted: Render mountain/valley folds as dotted lines (Morse-style for mountains, segment-dash for valleys).
  • --folds-color <color1_hex> <color2_hex>: Color mountain/valley folds with specified hex codes (e.g., #FF0000 #0000FF). Can be combined with --folds-dotted for dashed variants.
  • --theta: Parallelogram angle for squarer units (60-80°; default 60).

Usage

Default generation (letter size, compactness 7, black lines):

python miura_fold.py

Outputs: miura_fold.svg.

Custom example (300mm x 400mm, compactness 5, green/magenta dotted folds):

python miura_fold.py --compact 5 --mm 400x300 --folds-color #00FF00 #FF00FF --folds-dotted --output custom.svg

Notes

  • Use tools like Inkscape for post-processing.

  • Theta fitting: The --theta value sets a target for the parallelogram angle, but the script flexes it slightly to ensure an integer number of rows/columns fit the paper exactly. Check the console output for the "Final theta" (e.g., "78.5° (target 80°)"); this adjusted angle maintains the pattern's integrity without gaps or overflows.

Code

View source: miura_fold.py

License

This Python script is released under the MIT License.

About

X: @5ynthaire
GitHub: https://github.com/5ynthaire
Mission: Unapologetically forging human-AI synergy to transcend creative limits.
Attribution: Created with Grok by xAI (no affiliation).

About

Python script for generating Miura fold crease patterns in SVG—auto-fits to paper size with customizable compactness and angles. Print, score, fold: no math needed.

Topics

Resources

License

Stars

Watchers

Forks

Languages