2018-11-06 19:35:27 +00:00
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
from svgFunctions import *
|
2018-11-16 22:18:29 +00:00
|
|
|
import pyembroidery
|
|
|
|
from utilities import *
|
2018-11-06 19:35:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="Converts an SVG file into a PES embroidery file.")
|
|
|
|
|
|
|
|
parser.add_argument("-i", dest="inputFile", type=str, action='store', required=True)
|
2018-11-16 22:18:29 +00:00
|
|
|
parser.add_argument("-o", dest="outputFile", type=str, action='store', default="output.PES", required=False)
|
|
|
|
parser.add_argument("-d", dest="debug", action='store_true')
|
2018-11-06 19:35:27 +00:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Load the SVG file from disk
|
|
|
|
svg = loadVectorGraphic(args.inputFile)
|
|
|
|
paths, attributes = svg
|
|
|
|
if paths is None or attributes is None:
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
# Enumerate the shapes in the SVG to find where stitches should go.
|
|
|
|
for shape in paths:
|
2018-11-07 02:53:24 +00:00
|
|
|
stitchLines = makeStitchLines(shape)
|
2018-11-06 19:35:27 +00:00
|
|
|
print(shape)
|
2018-11-16 22:18:29 +00:00
|
|
|
|
|
|
|
if args.debug:
|
|
|
|
pes = pyembroidery.read(args.outputFile)
|
|
|
|
if pes is not None:
|
|
|
|
print("Generating debug image.")
|
|
|
|
pyembroidery.write_png(pes, replaceFilenameAndExtensionFromPath(args.inputFile, "debugPicture", "png"))
|
|
|
|
else:
|
|
|
|
print("Couldn't find output file.")
|