EmbroidePy / pyembroidery

pyembroidery library for reading and writing a variety of embroidery formats.
MIT License
181 stars 33 forks source link

Import GenericWriter Correctly #146

Closed tatarize closed 2 years ago

tatarize commented 2 years ago

Correct the generic writer input to permit external scripting

from pyembroidery import *
import sys

gcode_writer_dict = {
    "scale": (0.1, -0.1),
    "thread_change_command": NEEDLE_SET,
    "write_speeds": True,
    "pattern_start": "G21 G90 F6000 (mm units, absolute positioning, speed)\n",
    "thread_entry": "(Thread{thread_index}: {thread_color} {thread_description} {thread_brand} {thread_catalog_number})\n",
    "color_start": "G00 X{x:.3f} Y{y:.3f} (Starting new location)\n",
    "stitch": "G01 X{x:.3f} Y{y:.3f}\n",
    "slow": "F1000\n",
    "fast": "F6000\n",
    "needle_set": {None: ("{cmd_needle}", "default value {cmd_needle}\n"), "1": "G0A51\n", "2": "G0B8\n"},
    "end": "M30\n",
}

EmbPattern.write_embroidery(
    GenericWriter,
    EmbPattern(sys.argv[1]),
    f"{sys.argv[1]}.gcode",
    gcode_writer_dict,
)