From dfbe6f9c0f12be693454390f5e92bb3dd06661cf Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 6 Apr 2018 19:55:53 -0400 Subject: embroider_input.py: input extension to read embroidery formats --- bin/gen-format-list | 19 -------------- bin/gen-input-inx | 19 ++++++++++++++ bin/gen-output-format-option-list | 19 ++++++++++++++ embroider_input.py | 51 ++++++++++++++++++++++++++++++++++++ inkstitch/stitch_plan/stitch_plan.py | 26 +++++++++++++++--- templates/embroider_input.inx | 17 ++++++++++++ 6 files changed, 129 insertions(+), 22 deletions(-) delete mode 100755 bin/gen-format-list create mode 100755 bin/gen-input-inx create mode 100755 bin/gen-output-format-option-list create mode 100644 embroider_input.py create mode 100644 templates/embroider_input.inx diff --git a/bin/gen-format-list b/bin/gen-format-list deleted file mode 100755 index 674813bb..00000000 --- a/bin/gen-format-list +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python - -import sys - -sys.path.append('embroidermodder/experimental/python/binding') -from libembroidery import * - -formatList = embFormatList_create() -curFormat = formatList -while(curFormat): - extension = embFormat_extension(curFormat) - description = embFormat_description(curFormat) - writerState = embFormat_writerState(curFormat) - - if writerState.strip() and embFormat_type(curFormat) != EMBFORMAT_OBJECTONLY: - print '<_option value="%s">%s(%s)' % (extension[1:], description, extension.upper()) - - curFormat = curFormat.next - diff --git a/bin/gen-input-inx b/bin/gen-input-inx new file mode 100755 index 00000000..c88931ee --- /dev/null +++ b/bin/gen-input-inx @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import sys + +sys.path.append('embroidermodder/experimental/python/binding') +from libembroidery import * + +formatList = embFormatList_create() +curFormat = formatList +while(curFormat): + extension = embFormat_extension(curFormat) + description = embFormat_description(curFormat) + writerState = embFormat_readerState(curFormat) + + if writerState.strip() and embFormat_type(curFormat) != EMBFORMAT_OBJECTONLY: + print extension + + curFormat = curFormat.next + diff --git a/bin/gen-output-format-option-list b/bin/gen-output-format-option-list new file mode 100755 index 00000000..674813bb --- /dev/null +++ b/bin/gen-output-format-option-list @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import sys + +sys.path.append('embroidermodder/experimental/python/binding') +from libembroidery import * + +formatList = embFormatList_create() +curFormat = formatList +while(curFormat): + extension = embFormat_extension(curFormat) + description = embFormat_description(curFormat) + writerState = embFormat_writerState(curFormat) + + if writerState.strip() and embFormat_type(curFormat) != EMBFORMAT_OBJECTONLY: + print '<_option value="%s">%s(%s)' % (extension[1:], description, extension.upper()) + + curFormat = curFormat.next + diff --git a/embroider_input.py b/embroider_input.py new file mode 100644 index 00000000..39a0e424 --- /dev/null +++ b/embroider_input.py @@ -0,0 +1,51 @@ +import sys +from libembroidery import * +from inkex import etree +import inkex +from inkstitch import PIXELS_PER_MM, _ +from inkstitch.stitch_plan import StitchPlan +from inkstitch.svg import render_stitch_plan + + +def pattern_stitches(pattern): + stitch_pointer = pattern.stitchList + while stitch_pointer: + yield stitch_pointer.stitch + stitch_pointer = stitch_pointer.next + + +def main(embroidery_file): + pattern = embPattern_create() + embPattern_read(pattern, embroidery_file) + embPattern_flipVertical(pattern) + + stitch_plan = StitchPlan() + color_block = None + current_color = None + + for stitch in pattern_stitches(pattern): + if stitch.color != current_color: + thread = embThreadList_getAt(pattern.threadList, stitch.color) + color = thread.color + color_block = stitch_plan.new_color_block((color.r, color.g, color.b)) + current_color = stitch.color + + if not stitch.flags & END: + color_block.add_stitch(stitch.xx * PIXELS_PER_MM, stitch.yy * PIXELS_PER_MM, + jump=stitch.flags & JUMP, + stop=stitch.flags & STOP, + trim=stitch.flags & TRIM) + + dimensions = stitch_plan.dimensions + svg = etree.Element("svg", nsmap=inkex.NSS, attrib= + { + "width": "%s" % dimensions[0], + "height": "%s" % dimensions[1], + "viewBox": "0 0 %s %s" % dimensions, + }) + render_stitch_plan(svg, stitch_plan) + + print etree.tostring(svg) + +if __name__ == '__main__': + sys.exit(main(*sys.argv[1:])) diff --git a/inkstitch/stitch_plan/stitch_plan.py b/inkstitch/stitch_plan/stitch_plan.py index 82584bbc..0e638f16 100644 --- a/inkstitch/stitch_plan/stitch_plan.py +++ b/inkstitch/stitch_plan/stitch_plan.py @@ -96,11 +96,22 @@ class StitchPlan(object): def num_stitches(self): return sum(block.num_stitches for block in self) + @property + def dimensions(self): + color_block_bounding_boxes = [cb.bounding_box for cb in self] + minx = min(bb[0] for bb in color_block_bounding_boxes) + miny = min(bb[1] for bb in color_block_bounding_boxes) + maxx = max(bb[2] for bb in color_block_bounding_boxes) + maxy = max(bb[3] for bb in color_block_bounding_boxes) + + import sys; print >> sys.stderr, color_block_bounding_boxes, minx, miny, maxx, maxy + + return (maxx - minx, maxy - miny) + @property def dimensions_mm(self): - # TODO: implement this. Should do a bounding box calculation and - # convert to millimeters. - return "" + dimensions = self.dimensions + return (dimensions[0] / PIXELS_PER_MM, dimensions[1] / PIXELS_PER_MM) class ColorBlock(object): @@ -196,3 +207,12 @@ class ColorBlock(object): def replace_stitches(self, stitches): self.stitches = stitches + + @property + def bounding_box(self): + minx = min(stitch.x for stitch in self) + miny = min(stitch.y for stitch in self) + maxx = max(stitch.x for stitch in self) + maxy = max(stitch.y for stitch in self) + + return minx, miny, maxx, maxy diff --git a/templates/embroider_input.inx b/templates/embroider_input.inx new file mode 100644 index 00000000..148784bc --- /dev/null +++ b/templates/embroider_input.inx @@ -0,0 +1,17 @@ + + + <_name>{{ format | upper }} file input + org.inkstitch.input.{{ format }} + embroider_input.py + inkex.py + + .{{ format }} + application/x-embroidery-{{ format }} + <_filetypename>{{ description }} (.{{ format }}) + <_filetypetooltip>convert {{ format | upper }} file to Ink/Stitch manual-stitch paths + + + + -- cgit v1.2.3 From 24ed1de2de1201cd3a8988de4360da5d79981e16 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 9 Apr 2018 20:07:33 -0400 Subject: generator for input format INX files --- bin/gen-input-inx | 50 ++++++++++++++++++++++++++++++++----------- templates/embroider_input.inx | 2 +- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/bin/gen-input-inx b/bin/gen-input-inx index c88931ee..5d65acca 100755 --- a/bin/gen-input-inx +++ b/bin/gen-input-inx @@ -1,19 +1,45 @@ #!/usr/bin/env python -import sys - -sys.path.append('embroidermodder/experimental/python/binding') +import sys, os +from os.path import dirname from libembroidery import * +from jinja2 import Environment, FileSystemLoader, select_autoescape + + +def build_environment(): + template_dir = os.path.join(dirname(dirname(os.path.realpath(__file__))), "templates") + + return Environment( + loader = FileSystemLoader(template_dir), + autoescape = select_autoescape(['xml']) + ) + + +def libembroidery_input_formats(): + formatList = embFormatList_create() + curFormat = formatList + while(curFormat): + extension = embFormat_extension(curFormat) + description = embFormat_description(curFormat) + writerState = embFormat_readerState(curFormat) + + if writerState.strip() and embFormat_type(curFormat) != EMBFORMAT_OBJECTONLY: + # extension includes the dot, so we'll remove it + yield extension[1:], description + + curFormat = curFormat.next + + +def main(): + env = build_environment() + template = env.get_template('embroider_input.inx') -formatList = embFormatList_create() -curFormat = formatList -while(curFormat): - extension = embFormat_extension(curFormat) - description = embFormat_description(curFormat) - writerState = embFormat_readerState(curFormat) + for format, description in libembroidery_input_formats(): + inx = template.render(format=format, description=description) - if writerState.strip() and embFormat_type(curFormat) != EMBFORMAT_OBJECTONLY: - print extension + with open("embroider_input_%s.inx" % format.upper(), 'w') as inx_file: + inx_file.write(inx) - curFormat = curFormat.next +if __name__ == "__main__": + sys.exit(main()) diff --git a/templates/embroider_input.inx b/templates/embroider_input.inx index 148784bc..3af8f79e 100644 --- a/templates/embroider_input.inx +++ b/templates/embroider_input.inx @@ -7,7 +7,7 @@ .{{ format }} application/x-embroidery-{{ format }} - <_filetypename>{{ description }} (.{{ format }}) + <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) <_filetypetooltip>convert {{ format | upper }} file to Ink/Stitch manual-stitch paths - diff --git a/embroider_params.inx b/embroider_params.inx deleted file mode 100644 index f3987502..00000000 --- a/embroider_params.inx +++ /dev/null @@ -1,16 +0,0 @@ - - - <_name>Params - jonh.embroider.params - embroider_params.py - inkex.py - - all - - - - - - diff --git a/embroider_print.inx b/embroider_print.inx deleted file mode 100644 index cbba82cc..00000000 --- a/embroider_print.inx +++ /dev/null @@ -1,16 +0,0 @@ - - - <_name>Print - jonh.embroider.print - embroider_print.py - inkex.py - - all - - - - - - diff --git a/embroider_simulate.inx b/embroider_simulate.inx deleted file mode 100644 index 9c38ec97..00000000 --- a/embroider_simulate.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>Simulate - jonh.embroider.simulate - embroider_simulate.py - inkex.py - - - all - - - - - - diff --git a/inx/embroider.inx b/inx/embroider.inx new file mode 100644 index 00000000..74217b73 --- /dev/null +++ b/inx/embroider.inx @@ -0,0 +1,44 @@ + + + <_name>Embroider + jonh.embroider + embroider.py + inkex.py + _gui-description="Jump stitches smaller than this will be treated as normal stitches.">3.0 + true + + <_option value="csv">Comma Separated Values Format(.CSV) + <_option value="col">Embroidery Thread Color Format(.COL) + <_option value="dst">Tajima Embroidery Format(.DST) + <_option value="edr">Embird Embroidery Format(.EDR) + <_option value="exp">Melco Embroidery Format(.EXP) + <_option value="hus">Husqvarna Viking Embroidery Format(.HUS) + <_option value="inf">Embroidery Color Format(.INF) + <_option value="jef">Janome Embroidery Format(.JEF) + <_option value="ksm">Pfaff Embroidery Format(.KSM) + <_option value="max">Pfaff Embroidery Format(.MAX) + <_option value="pcd">Pfaff Embroidery Format(.PCD) + <_option value="pcq">Pfaff Embroidery Format(.PCQ) + <_option value="pcs">Pfaff Embroidery Format(.PCS) + <_option value="pec">Brother Embroidery Format(.PEC) + <_option value="pes">Brother Embroidery Format(.PES) + <_option value="plt">AutoCAD Plot Drawing Format(.PLT) + <_option value="rgb">RGB Embroidery Format(.RGB) + <_option value="sew">Janome Embroidery Format(.SEW) + <_option value="tap">Happy Embroidery Format(.TAP) + <_option value="thr">ThredWorks Embroidery Format(.THR) + <_option value="txt">Text File(.TXT) + <_option value="vp3">Pfaff Embroidery Format(.VP3) + <_option value="xxx">Singer Embroidery Format(.XXX) + + + + all + + + + + + diff --git a/inx/embroider_input_100.inx b/inx/embroider_input_100.inx new file mode 100644 index 00000000..9bbad780 --- /dev/null +++ b/inx/embroider_input_100.inx @@ -0,0 +1,16 @@ + + + <_name>100 file input + org.inkstitch.input.100 + embroider_input.py + inkex.py + + .100 + application/x-embroidery-100 + <_filetypename>Ink/Stitch: Toyota Embroidery Format (.100) + <_filetypetooltip>convert 100 file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_10O.inx b/inx/embroider_input_10O.inx new file mode 100644 index 00000000..42f1850e --- /dev/null +++ b/inx/embroider_input_10O.inx @@ -0,0 +1,16 @@ + + + <_name>10O file input + org.inkstitch.input.10o + embroider_input.py + inkex.py + + .10o + application/x-embroidery-10o + <_filetypename>Ink/Stitch: Toyota Embroidery Format (.10o) + <_filetypetooltip>convert 10O file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_BRO.inx b/inx/embroider_input_BRO.inx new file mode 100644 index 00000000..64a1bcda --- /dev/null +++ b/inx/embroider_input_BRO.inx @@ -0,0 +1,16 @@ + + + <_name>BRO file input + org.inkstitch.input.bro + embroider_input.py + inkex.py + + .bro + application/x-embroidery-bro + <_filetypename>Ink/Stitch: Bits & Volts Embroidery Format (.bro) + <_filetypetooltip>convert BRO file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_COL.inx b/inx/embroider_input_COL.inx new file mode 100644 index 00000000..81002dd7 --- /dev/null +++ b/inx/embroider_input_COL.inx @@ -0,0 +1,16 @@ + + + <_name>COL file input + org.inkstitch.input.col + embroider_input.py + inkex.py + + .col + application/x-embroidery-col + <_filetypename>Ink/Stitch: Embroidery Thread Color Format (.col) + <_filetypetooltip>convert COL file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_CSD.inx b/inx/embroider_input_CSD.inx new file mode 100644 index 00000000..8ebb94b9 --- /dev/null +++ b/inx/embroider_input_CSD.inx @@ -0,0 +1,16 @@ + + + <_name>CSD file input + org.inkstitch.input.csd + embroider_input.py + inkex.py + + .csd + application/x-embroidery-csd + <_filetypename>Ink/Stitch: Singer Embroidery Format (.csd) + <_filetypetooltip>convert CSD file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_CSV.inx b/inx/embroider_input_CSV.inx new file mode 100644 index 00000000..c3f972d9 --- /dev/null +++ b/inx/embroider_input_CSV.inx @@ -0,0 +1,16 @@ + + + <_name>CSV file input + org.inkstitch.input.csv + embroider_input.py + inkex.py + + .csv + application/x-embroidery-csv + <_filetypename>Ink/Stitch: Comma Separated Values Format (.csv) + <_filetypetooltip>convert CSV file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_DAT.inx b/inx/embroider_input_DAT.inx new file mode 100644 index 00000000..1045153a --- /dev/null +++ b/inx/embroider_input_DAT.inx @@ -0,0 +1,16 @@ + + + <_name>DAT file input + org.inkstitch.input.dat + embroider_input.py + inkex.py + + .dat + application/x-embroidery-dat + <_filetypename>Ink/Stitch: Barudan Embroidery Format (.dat) + <_filetypetooltip>convert DAT file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_DSB.inx b/inx/embroider_input_DSB.inx new file mode 100644 index 00000000..f81c7ca2 --- /dev/null +++ b/inx/embroider_input_DSB.inx @@ -0,0 +1,16 @@ + + + <_name>DSB file input + org.inkstitch.input.dsb + embroider_input.py + inkex.py + + .dsb + application/x-embroidery-dsb + <_filetypename>Ink/Stitch: Barudan Embroidery Format (.dsb) + <_filetypetooltip>convert DSB file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_DST.inx b/inx/embroider_input_DST.inx new file mode 100644 index 00000000..414b7470 --- /dev/null +++ b/inx/embroider_input_DST.inx @@ -0,0 +1,16 @@ + + + <_name>DST file input + org.inkstitch.input.dst + embroider_input.py + inkex.py + + .dst + application/x-embroidery-dst + <_filetypename>Ink/Stitch: Tajima Embroidery Format (.dst) + <_filetypetooltip>convert DST file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_DSZ.inx b/inx/embroider_input_DSZ.inx new file mode 100644 index 00000000..9c81a0ad --- /dev/null +++ b/inx/embroider_input_DSZ.inx @@ -0,0 +1,16 @@ + + + <_name>DSZ file input + org.inkstitch.input.dsz + embroider_input.py + inkex.py + + .dsz + application/x-embroidery-dsz + <_filetypename>Ink/Stitch: ZSK USA Embroidery Format (.dsz) + <_filetypetooltip>convert DSZ file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_EDR.inx b/inx/embroider_input_EDR.inx new file mode 100644 index 00000000..9276fd17 --- /dev/null +++ b/inx/embroider_input_EDR.inx @@ -0,0 +1,16 @@ + + + <_name>EDR file input + org.inkstitch.input.edr + embroider_input.py + inkex.py + + .edr + application/x-embroidery-edr + <_filetypename>Ink/Stitch: Embird Embroidery Format (.edr) + <_filetypetooltip>convert EDR file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_EMD.inx b/inx/embroider_input_EMD.inx new file mode 100644 index 00000000..bb20f977 --- /dev/null +++ b/inx/embroider_input_EMD.inx @@ -0,0 +1,16 @@ + + + <_name>EMD file input + org.inkstitch.input.emd + embroider_input.py + inkex.py + + .emd + application/x-embroidery-emd + <_filetypename>Ink/Stitch: Elna Embroidery Format (.emd) + <_filetypetooltip>convert EMD file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_EXP.inx b/inx/embroider_input_EXP.inx new file mode 100644 index 00000000..41bae8ce --- /dev/null +++ b/inx/embroider_input_EXP.inx @@ -0,0 +1,16 @@ + + + <_name>EXP file input + org.inkstitch.input.exp + embroider_input.py + inkex.py + + .exp + application/x-embroidery-exp + <_filetypename>Ink/Stitch: Melco Embroidery Format (.exp) + <_filetypetooltip>convert EXP file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_EXY.inx b/inx/embroider_input_EXY.inx new file mode 100644 index 00000000..a2e792c4 --- /dev/null +++ b/inx/embroider_input_EXY.inx @@ -0,0 +1,16 @@ + + + <_name>EXY file input + org.inkstitch.input.exy + embroider_input.py + inkex.py + + .exy + application/x-embroidery-exy + <_filetypename>Ink/Stitch: Eltac Embroidery Format (.exy) + <_filetypetooltip>convert EXY file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_FXY.inx b/inx/embroider_input_FXY.inx new file mode 100644 index 00000000..4d77022e --- /dev/null +++ b/inx/embroider_input_FXY.inx @@ -0,0 +1,16 @@ + + + <_name>FXY file input + org.inkstitch.input.fxy + embroider_input.py + inkex.py + + .fxy + application/x-embroidery-fxy + <_filetypename>Ink/Stitch: Fortron Embroidery Format (.fxy) + <_filetypetooltip>convert FXY file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_GT.inx b/inx/embroider_input_GT.inx new file mode 100644 index 00000000..3b482244 --- /dev/null +++ b/inx/embroider_input_GT.inx @@ -0,0 +1,16 @@ + + + <_name>GT file input + org.inkstitch.input.gt + embroider_input.py + inkex.py + + .gt + application/x-embroidery-gt + <_filetypename>Ink/Stitch: Gold Thread Embroidery Format (.gt) + <_filetypetooltip>convert GT file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_HUS.inx b/inx/embroider_input_HUS.inx new file mode 100644 index 00000000..3b19ee87 --- /dev/null +++ b/inx/embroider_input_HUS.inx @@ -0,0 +1,16 @@ + + + <_name>HUS file input + org.inkstitch.input.hus + embroider_input.py + inkex.py + + .hus + application/x-embroidery-hus + <_filetypename>Ink/Stitch: Husqvarna Viking Embroidery Format (.hus) + <_filetypetooltip>convert HUS file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_INB.inx b/inx/embroider_input_INB.inx new file mode 100644 index 00000000..24c6535d --- /dev/null +++ b/inx/embroider_input_INB.inx @@ -0,0 +1,16 @@ + + + <_name>INB file input + org.inkstitch.input.inb + embroider_input.py + inkex.py + + .inb + application/x-embroidery-inb + <_filetypename>Ink/Stitch: Inbro Embroidery Format (.inb) + <_filetypetooltip>convert INB file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_INF.inx b/inx/embroider_input_INF.inx new file mode 100644 index 00000000..db7e5d57 --- /dev/null +++ b/inx/embroider_input_INF.inx @@ -0,0 +1,16 @@ + + + <_name>INF file input + org.inkstitch.input.inf + embroider_input.py + inkex.py + + .inf + application/x-embroidery-inf + <_filetypename>Ink/Stitch: Embroidery Color Format (.inf) + <_filetypetooltip>convert INF file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_JEF.inx b/inx/embroider_input_JEF.inx new file mode 100644 index 00000000..c2030622 --- /dev/null +++ b/inx/embroider_input_JEF.inx @@ -0,0 +1,16 @@ + + + <_name>JEF file input + org.inkstitch.input.jef + embroider_input.py + inkex.py + + .jef + application/x-embroidery-jef + <_filetypename>Ink/Stitch: Janome Embroidery Format (.jef) + <_filetypetooltip>convert JEF file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_KSM.inx b/inx/embroider_input_KSM.inx new file mode 100644 index 00000000..2869ea07 --- /dev/null +++ b/inx/embroider_input_KSM.inx @@ -0,0 +1,16 @@ + + + <_name>KSM file input + org.inkstitch.input.ksm + embroider_input.py + inkex.py + + .ksm + application/x-embroidery-ksm + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.ksm) + <_filetypetooltip>convert KSM file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_MAX.inx b/inx/embroider_input_MAX.inx new file mode 100644 index 00000000..2dbbe2cc --- /dev/null +++ b/inx/embroider_input_MAX.inx @@ -0,0 +1,16 @@ + + + <_name>MAX file input + org.inkstitch.input.max + embroider_input.py + inkex.py + + .max + application/x-embroidery-max + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.max) + <_filetypetooltip>convert MAX file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_MIT.inx b/inx/embroider_input_MIT.inx new file mode 100644 index 00000000..10f5dfd3 --- /dev/null +++ b/inx/embroider_input_MIT.inx @@ -0,0 +1,16 @@ + + + <_name>MIT file input + org.inkstitch.input.mit + embroider_input.py + inkex.py + + .mit + application/x-embroidery-mit + <_filetypename>Ink/Stitch: Mitsubishi Embroidery Format (.mit) + <_filetypetooltip>convert MIT file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_NEW.inx b/inx/embroider_input_NEW.inx new file mode 100644 index 00000000..f13a7009 --- /dev/null +++ b/inx/embroider_input_NEW.inx @@ -0,0 +1,16 @@ + + + <_name>NEW file input + org.inkstitch.input.new + embroider_input.py + inkex.py + + .new + application/x-embroidery-new + <_filetypename>Ink/Stitch: Ameco Embroidery Format (.new) + <_filetypetooltip>convert NEW file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_OFM.inx b/inx/embroider_input_OFM.inx new file mode 100644 index 00000000..9086900d --- /dev/null +++ b/inx/embroider_input_OFM.inx @@ -0,0 +1,16 @@ + + + <_name>OFM file input + org.inkstitch.input.ofm + embroider_input.py + inkex.py + + .ofm + application/x-embroidery-ofm + <_filetypename>Ink/Stitch: Melco Embroidery Format (.ofm) + <_filetypetooltip>convert OFM file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PCD.inx b/inx/embroider_input_PCD.inx new file mode 100644 index 00000000..fc9c7362 --- /dev/null +++ b/inx/embroider_input_PCD.inx @@ -0,0 +1,16 @@ + + + <_name>PCD file input + org.inkstitch.input.pcd + embroider_input.py + inkex.py + + .pcd + application/x-embroidery-pcd + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.pcd) + <_filetypetooltip>convert PCD file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PCM.inx b/inx/embroider_input_PCM.inx new file mode 100644 index 00000000..fe6c3e22 --- /dev/null +++ b/inx/embroider_input_PCM.inx @@ -0,0 +1,16 @@ + + + <_name>PCM file input + org.inkstitch.input.pcm + embroider_input.py + inkex.py + + .pcm + application/x-embroidery-pcm + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.pcm) + <_filetypetooltip>convert PCM file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PCQ.inx b/inx/embroider_input_PCQ.inx new file mode 100644 index 00000000..932a9568 --- /dev/null +++ b/inx/embroider_input_PCQ.inx @@ -0,0 +1,16 @@ + + + <_name>PCQ file input + org.inkstitch.input.pcq + embroider_input.py + inkex.py + + .pcq + application/x-embroidery-pcq + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.pcq) + <_filetypetooltip>convert PCQ file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PCS.inx b/inx/embroider_input_PCS.inx new file mode 100644 index 00000000..d9d058c0 --- /dev/null +++ b/inx/embroider_input_PCS.inx @@ -0,0 +1,16 @@ + + + <_name>PCS file input + org.inkstitch.input.pcs + embroider_input.py + inkex.py + + .pcs + application/x-embroidery-pcs + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.pcs) + <_filetypetooltip>convert PCS file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PEC.inx b/inx/embroider_input_PEC.inx new file mode 100644 index 00000000..382dedff --- /dev/null +++ b/inx/embroider_input_PEC.inx @@ -0,0 +1,16 @@ + + + <_name>PEC file input + org.inkstitch.input.pec + embroider_input.py + inkex.py + + .pec + application/x-embroidery-pec + <_filetypename>Ink/Stitch: Brother Embroidery Format (.pec) + <_filetypetooltip>convert PEC file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PES.inx b/inx/embroider_input_PES.inx new file mode 100644 index 00000000..451a4da6 --- /dev/null +++ b/inx/embroider_input_PES.inx @@ -0,0 +1,16 @@ + + + <_name>PES file input + org.inkstitch.input.pes + embroider_input.py + inkex.py + + .pes + application/x-embroidery-pes + <_filetypename>Ink/Stitch: Brother Embroidery Format (.pes) + <_filetypetooltip>convert PES file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PHB.inx b/inx/embroider_input_PHB.inx new file mode 100644 index 00000000..ab4daf67 --- /dev/null +++ b/inx/embroider_input_PHB.inx @@ -0,0 +1,16 @@ + + + <_name>PHB file input + org.inkstitch.input.phb + embroider_input.py + inkex.py + + .phb + application/x-embroidery-phb + <_filetypename>Ink/Stitch: Brother Embroidery Format (.phb) + <_filetypetooltip>convert PHB file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PHC.inx b/inx/embroider_input_PHC.inx new file mode 100644 index 00000000..e36739af --- /dev/null +++ b/inx/embroider_input_PHC.inx @@ -0,0 +1,16 @@ + + + <_name>PHC file input + org.inkstitch.input.phc + embroider_input.py + inkex.py + + .phc + application/x-embroidery-phc + <_filetypename>Ink/Stitch: Brother Embroidery Format (.phc) + <_filetypetooltip>convert PHC file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_PLT.inx b/inx/embroider_input_PLT.inx new file mode 100644 index 00000000..ec2374da --- /dev/null +++ b/inx/embroider_input_PLT.inx @@ -0,0 +1,16 @@ + + + <_name>PLT file input + org.inkstitch.input.plt + embroider_input.py + inkex.py + + .plt + application/x-embroidery-plt + <_filetypename>Ink/Stitch: AutoCAD Plot Drawing Format (.plt) + <_filetypetooltip>convert PLT file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_RGB.inx b/inx/embroider_input_RGB.inx new file mode 100644 index 00000000..a73955c1 --- /dev/null +++ b/inx/embroider_input_RGB.inx @@ -0,0 +1,16 @@ + + + <_name>RGB file input + org.inkstitch.input.rgb + embroider_input.py + inkex.py + + .rgb + application/x-embroidery-rgb + <_filetypename>Ink/Stitch: RGB Embroidery Format (.rgb) + <_filetypetooltip>convert RGB file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_SEW.inx b/inx/embroider_input_SEW.inx new file mode 100644 index 00000000..8cb41136 --- /dev/null +++ b/inx/embroider_input_SEW.inx @@ -0,0 +1,16 @@ + + + <_name>SEW file input + org.inkstitch.input.sew + embroider_input.py + inkex.py + + .sew + application/x-embroidery-sew + <_filetypename>Ink/Stitch: Janome Embroidery Format (.sew) + <_filetypetooltip>convert SEW file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_SHV.inx b/inx/embroider_input_SHV.inx new file mode 100644 index 00000000..20735cc8 --- /dev/null +++ b/inx/embroider_input_SHV.inx @@ -0,0 +1,16 @@ + + + <_name>SHV file input + org.inkstitch.input.shv + embroider_input.py + inkex.py + + .shv + application/x-embroidery-shv + <_filetypename>Ink/Stitch: Husqvarna Viking Embroidery Format (.shv) + <_filetypetooltip>convert SHV file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_SST.inx b/inx/embroider_input_SST.inx new file mode 100644 index 00000000..61f7c782 --- /dev/null +++ b/inx/embroider_input_SST.inx @@ -0,0 +1,16 @@ + + + <_name>SST file input + org.inkstitch.input.sst + embroider_input.py + inkex.py + + .sst + application/x-embroidery-sst + <_filetypename>Ink/Stitch: Sunstar Embroidery Format (.sst) + <_filetypetooltip>convert SST file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_STX.inx b/inx/embroider_input_STX.inx new file mode 100644 index 00000000..5043d6f2 --- /dev/null +++ b/inx/embroider_input_STX.inx @@ -0,0 +1,16 @@ + + + <_name>STX file input + org.inkstitch.input.stx + embroider_input.py + inkex.py + + .stx + application/x-embroidery-stx + <_filetypename>Ink/Stitch: Data Stitch Embroidery Format (.stx) + <_filetypetooltip>convert STX file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_T01.inx b/inx/embroider_input_T01.inx new file mode 100644 index 00000000..5090310e --- /dev/null +++ b/inx/embroider_input_T01.inx @@ -0,0 +1,16 @@ + + + <_name>T01 file input + org.inkstitch.input.t01 + embroider_input.py + inkex.py + + .t01 + application/x-embroidery-t01 + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.t01) + <_filetypetooltip>convert T01 file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_T09.inx b/inx/embroider_input_T09.inx new file mode 100644 index 00000000..5c64541d --- /dev/null +++ b/inx/embroider_input_T09.inx @@ -0,0 +1,16 @@ + + + <_name>T09 file input + org.inkstitch.input.t09 + embroider_input.py + inkex.py + + .t09 + application/x-embroidery-t09 + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.t09) + <_filetypetooltip>convert T09 file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_TAP.inx b/inx/embroider_input_TAP.inx new file mode 100644 index 00000000..496105e2 --- /dev/null +++ b/inx/embroider_input_TAP.inx @@ -0,0 +1,16 @@ + + + <_name>TAP file input + org.inkstitch.input.tap + embroider_input.py + inkex.py + + .tap + application/x-embroidery-tap + <_filetypename>Ink/Stitch: Happy Embroidery Format (.tap) + <_filetypetooltip>convert TAP file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_THR.inx b/inx/embroider_input_THR.inx new file mode 100644 index 00000000..d01d6184 --- /dev/null +++ b/inx/embroider_input_THR.inx @@ -0,0 +1,16 @@ + + + <_name>THR file input + org.inkstitch.input.thr + embroider_input.py + inkex.py + + .thr + application/x-embroidery-thr + <_filetypename>Ink/Stitch: ThredWorks Embroidery Format (.thr) + <_filetypetooltip>convert THR file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_U00.inx b/inx/embroider_input_U00.inx new file mode 100644 index 00000000..a98ddaa1 --- /dev/null +++ b/inx/embroider_input_U00.inx @@ -0,0 +1,16 @@ + + + <_name>U00 file input + org.inkstitch.input.u00 + embroider_input.py + inkex.py + + .u00 + application/x-embroidery-u00 + <_filetypename>Ink/Stitch: Barudan Embroidery Format (.u00) + <_filetypetooltip>convert U00 file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_VIP.inx b/inx/embroider_input_VIP.inx new file mode 100644 index 00000000..f607bfd7 --- /dev/null +++ b/inx/embroider_input_VIP.inx @@ -0,0 +1,16 @@ + + + <_name>VIP file input + org.inkstitch.input.vip + embroider_input.py + inkex.py + + .vip + application/x-embroidery-vip + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.vip) + <_filetypetooltip>convert VIP file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_VP3.inx b/inx/embroider_input_VP3.inx new file mode 100644 index 00000000..cb24f60a --- /dev/null +++ b/inx/embroider_input_VP3.inx @@ -0,0 +1,16 @@ + + + <_name>VP3 file input + org.inkstitch.input.vp3 + embroider_input.py + inkex.py + + .vp3 + application/x-embroidery-vp3 + <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.vp3) + <_filetypetooltip>convert VP3 file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_XXX.inx b/inx/embroider_input_XXX.inx new file mode 100644 index 00000000..64093628 --- /dev/null +++ b/inx/embroider_input_XXX.inx @@ -0,0 +1,16 @@ + + + <_name>XXX file input + org.inkstitch.input.xxx + embroider_input.py + inkex.py + + .xxx + application/x-embroidery-xxx + <_filetypename>Ink/Stitch: Singer Embroidery Format (.xxx) + <_filetypetooltip>convert XXX file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_input_ZSK.inx b/inx/embroider_input_ZSK.inx new file mode 100644 index 00000000..badb36da --- /dev/null +++ b/inx/embroider_input_ZSK.inx @@ -0,0 +1,16 @@ + + + <_name>ZSK file input + org.inkstitch.input.zsk + embroider_input.py + inkex.py + + .zsk + application/x-embroidery-zsk + <_filetypename>Ink/Stitch: ZSK USA Embroidery Format (.zsk) + <_filetypetooltip>convert ZSK file to Ink/Stitch manual-stitch paths + + + diff --git a/inx/embroider_params.inx b/inx/embroider_params.inx new file mode 100644 index 00000000..f3987502 --- /dev/null +++ b/inx/embroider_params.inx @@ -0,0 +1,16 @@ + + + <_name>Params + jonh.embroider.params + embroider_params.py + inkex.py + + all + + + + + + diff --git a/inx/embroider_print.inx b/inx/embroider_print.inx new file mode 100644 index 00000000..cbba82cc --- /dev/null +++ b/inx/embroider_print.inx @@ -0,0 +1,16 @@ + + + <_name>Print + jonh.embroider.print + embroider_print.py + inkex.py + + all + + + + + + diff --git a/inx/embroider_simulate.inx b/inx/embroider_simulate.inx new file mode 100644 index 00000000..9c38ec97 --- /dev/null +++ b/inx/embroider_simulate.inx @@ -0,0 +1,17 @@ + + + <_name>Simulate + jonh.embroider.simulate + embroider_simulate.py + inkex.py + + + all + + + + + + -- cgit v1.2.3 From 287275c1eb3c4af5b92b46f1f647d77527a7298a Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 9 Apr 2018 20:14:25 -0400 Subject: add embroider_input extension to Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b38bc787..21c3582c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -EXTENSIONS:=embroider embroider_params embroider_simulate embroider_print +EXTENSIONS:=embroider embroider_params embroider_simulate embroider_print embroider_input # This gets the branch name or the name of the tag VERSION:=$(TRAVIS_BRANCH) -- cgit v1.2.3 From b6866a6a339b57ba98e4d99dd568ff09a6de6a0c Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 9 Apr 2018 20:33:35 -0400 Subject: remove debug print --- inkstitch/stitch_plan/stitch_plan.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/inkstitch/stitch_plan/stitch_plan.py b/inkstitch/stitch_plan/stitch_plan.py index 0e638f16..a7f39f70 100644 --- a/inkstitch/stitch_plan/stitch_plan.py +++ b/inkstitch/stitch_plan/stitch_plan.py @@ -104,8 +104,6 @@ class StitchPlan(object): maxx = max(bb[2] for bb in color_block_bounding_boxes) maxy = max(bb[3] for bb in color_block_bounding_boxes) - import sys; print >> sys.stderr, color_block_bounding_boxes, minx, miny, maxx, maxy - return (maxx - minx, maxy - miny) @property -- cgit v1.2.3 From ea6f4e500a126fa30c8679db05116f7356eb06d0 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 10 Apr 2018 20:11:47 -0400 Subject: rename layer on import and remove id --- embroider_input.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/embroider_input.py b/embroider_input.py index 39a0e424..e3a7b0c2 100644 --- a/embroider_input.py +++ b/embroider_input.py @@ -1,8 +1,9 @@ import sys +import os from libembroidery import * from inkex import etree import inkex -from inkstitch import PIXELS_PER_MM, _ +from inkstitch import PIXELS_PER_MM, INKSCAPE_LABEL, _ from inkstitch.stitch_plan import StitchPlan from inkstitch.svg import render_stitch_plan @@ -45,6 +46,11 @@ def main(embroidery_file): }) render_stitch_plan(svg, stitch_plan) + # rename the Stitch Plan layer so that it doesn't get overwritten by Embroider + layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") + layer.set(INKSCAPE_LABEL, os.path.basename(embroidery_file)) + layer.attrib.pop('id') + print etree.tostring(svg) if __name__ == '__main__': -- cgit v1.2.3 From ac5cd68b0683aa6350d705eb7aff3bd8f4b73c75 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 10 Apr 2018 20:18:41 -0400 Subject: retain trims on import --- inkstitch/svg.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/inkstitch/svg.py b/inkstitch/svg.py index 66806d7a..0728309b 100644 --- a/inkstitch/svg.py +++ b/inkstitch/svg.py @@ -28,12 +28,12 @@ def get_correction_transform(svg): def color_block_to_paths(color_block, svg): - polylines = [] + paths = [] # We could emit just a single path with one subpath per point list, but # emitting multiple paths makes it easier for the user to manipulate them. for point_list in color_block_to_point_lists(color_block): color = color_block.color.visible_on_white.to_hex_str() - polylines.append(inkex.etree.Element( + paths.append(inkex.etree.Element( SVG_PATH_TAG, {'style': simplestyle.formatStyle( {'stroke': color, @@ -41,10 +41,15 @@ def color_block_to_paths(color_block, svg): 'fill': 'none'}), 'd': "M" + " ".join(" ".join(str(coord) for coord in point) for point in point_list), 'transform': get_correction_transform(svg), - 'embroider_manual_stitch': 'true' + 'embroider_manual_stitch': 'true', + 'embroider_trim_after': 'true', })) - return polylines + # no need to trim at the end of a thread color + if paths: + paths[-1].attrib.pop('embroider_trim_after') + + return paths def render_stitch_plan(svg, stitch_plan): -- cgit v1.2.3 From 468c2c137580c5aa408c9e070f66830666354b93 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 10 Apr 2018 20:21:57 -0400 Subject: fix autoescaping and BRO .inx --- bin/gen-input-inx | 2 +- inx/embroider_input_BRO.inx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/gen-input-inx b/bin/gen-input-inx index 08312f49..918adfb9 100755 --- a/bin/gen-input-inx +++ b/bin/gen-input-inx @@ -11,7 +11,7 @@ def build_environment(): return Environment( loader = FileSystemLoader(template_dir), - autoescape = select_autoescape(['xml']) + autoescape = True ) diff --git a/inx/embroider_input_BRO.inx b/inx/embroider_input_BRO.inx index 64a1bcda..0dc576bf 100644 --- a/inx/embroider_input_BRO.inx +++ b/inx/embroider_input_BRO.inx @@ -7,7 +7,7 @@ .bro application/x-embroidery-bro - <_filetypename>Ink/Stitch: Bits & Volts Embroidery Format (.bro) + <_filetypename>Ink/Stitch: Bits & Volts Embroidery Format (.bro) <_filetypetooltip>convert BRO file to Ink/Stitch manual-stitch paths