Threadsmith Stitch File Writer
Write Tajima DST or Melco EXP machine files from a stitch list or a Threadsmith project.
Try an example: Tiny square outline with a jump and a colour change → DST · Template project (name tag) → Melco EXP
How it works
Encodes stitches as a Tajima DST (512-byte header, balanced-ternary 3-byte records, jumps split to ≤ 12.1 mm, colour changes, trims as zero-sum jumps, END) or Melco EXP file. The file is decoded again to verify every stitch position before you download it.
- Coordinates are rounded to 0.1 mm on absolute positions, so rounding never accumulates; each move becomes the difference to the previous rounded position.
- DST: each axis is written in balanced ternary with digits for 1, 3, 9, 27 and 81 (±121 max). Byte 3 = 0x03 | flags: 0x80 jump, 0xC0 colour change; END = 00 00 F3. Longer moves are split into equal records. Y is inverted (DST is y-up).
- Trims are written as three jumps (+2,+2) (−4,−4) (+2,+2) that cancel out — the convention machines use to trigger a trim after a run of jumps.
- Header: LA label, ST record count, CO colour changes, ±X/±Y extents in 0.1 mm, AX/AY end offset, MX/MY 0, PD ******, 0x1A, padded with spaces to 512 bytes.
- EXP: 2 signed bytes per stitch (±127), 0x80 0x04 dx dy jump, 0x80 0x01 colour change; trims as three zero-sum jumps.
DST and EXP carry no thread colours: set the needle/colour order on the machine using the colour list from Threadsmith. Test on scrap fabric first.
Sources
- Embroidery format DST (header fields, ternary stitch encoding, control codes, trim convention) (EduTech Wiki, University of Geneva)
- Embroidery format EXP (2-byte two’s-complement stitches, 0x80 control codes) (EduTech Wiki, University of Geneva)
- pyembroidery – reference readers/writers for DST and EXP (EmbroidePy)
- Ink/Stitch manual – stitch types, underlay, pull compensation (Ink/Stitch project)
- Felzenszwalb & Huttenlocher, Distance Transforms of Sampled Functions, Theory of Computing 8 (2012)
For scripts and AI agents
- JSON API:
POST https://threadsmithstitchfile.usefulweb.site/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://threadsmithstitchfile.usefulweb.site/mcp· tool namethreadsmith_stitch_file
Example request
curl -s -X POST https://threadsmithstitchfile.usefulweb.site/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"format":"dst","label":"SQUARE","stitches":"[[0,0],[10,0],[10,10],[0,10],[0,0],[30,0,\"jump\"],[30,0,\"color\"],[30,0],[40,5],[30,10]]"}'Related tools
- Threadsmith Digitizer – Turn shapes, SVG paths, text or a whole project into embroidery stitches with stats and preview.
- Threadsmith Design Stats – Stitch count, colours, trims, thread, bobbin, sewing time and density of a DST/EXP file.