Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embroidery file formats?

Tags:

file-format

My wife has a Bernina embroidery machine and I'd like to experiment with creating designs programmatically. I'd like to either find out how to output data in a format the machine's software will accept, or else find a free or inexpensive utility that can convert from a format I can produce (such as HPGL, or something else documented) to a format the machine can accept. My intention would be to output a file with one XY coordinate per stitch, plus instructions to change thread (pause for thread change); I don't need something to generate area fills, adjust stitch spacing, optimize stitching order, etc.; I'd expect to handle those things myself.

Anyone have any suggestions?

like image 859
supercat Avatar asked Aug 15 '10 17:08

supercat


4 Answers

Bernina's .ART format is indeed proprietary, but Berinina owns a software company, OESD, that makes conversion software (e.g. the OESD Magic Box). You can create files using a documented file format, such as .PES, and use their software to convert the PES files into ART.

Here's a resource on the layout of some of the embroidery file formats

disclaimer: the company I work for sells OESD products.

like image 196
John Douthat Avatar answered Sep 30 '22 09:09

John Douthat


You could look at the open source Embroidermodder 2 and it's underlying library, libembroidery. At the time of writing, it doesn't support .ART, but .DST is a common format that most machines support which may work for you. Also, you could use libembroidery's .CSV format to lay out your stitches fairly easily so that all the format specifics are abstracted away and then convert the file with libembroidery-convert to an embroidery format that your machine supports. The .CSV format has the capability of specifying color changes, jump stitches and trimming.

libembroidery formats

like image 27
redteam316 Avatar answered Sep 30 '22 10:09

redteam316


According to this thread (admittedly a few years old, so maybe they've opened up recently) the details of the .art file format is closely guarded by Bernina and not made available to developers, requiring that all work is done through their official design tools.

I would think you could reverse engineer the file format with some trial-and-error modification of the .art file bytes, but the trick is getting those modified files back into the machine. Perhaps a good start would be to modify some bytes and then try to get their design software to re-open the file. The big gotcha with this approach would be if they use a checksum.

like image 44
G__ Avatar answered Sep 30 '22 09:09

G__


It occurs to me that there's actually a very strong possibility that a Bernina embroidery machine accepts .DST files. While .ART is somewhat standard to make such files, a lot of embroidery machines accept .DST and those are easy to code up and output.


.art files are in "Compound File Binary Format". You split them up pretty easily. 7zip will do this. And anybody could write anything to traverse this. Inside the files however, there are usually:

  • [5]SummaryInformation
  • [5]WilcomDesignInformationDDD
  • AUX_INFO
  • Contents
  • DESIGN_ICON

So far though, so good.

Do note this is the same as the .emb format by Wilcom (tho .art calls this breakdown Grade C, because it doesn't contain the vector art file which is similarly compressed when it exists in emb)

In .emb the Contents file starts with a 4 byte little endian number indicating the size of the file in uncompressed format. Followed by a zlib compression stream. The resulting data clearly has an embroidery file with strings about the threads and a triplet code.

So that's certainly doable, but the OP is about .art. And here's where there's an slight snag. Where the 00 is it looks like there are D2 which generally would suggest a single byte swizzle.

F1 47 D2 D2 EE 9C 24 --- should be  
46 2B 00 00 78 9C ED --- (the icon file sizes are always the same)

The bit swizzle here is: XOR D2, cycle-shift-left 1.

So the contents element in the CFBF should be unswizzled XOR 0xD2, circular shifted left by 1. Then the first four bytes are size, and the rest are a zlib compression stream.


import compoundfiles
import zlib


def swizzle(b):
    b ^= 0xD2
    b <<= 1
    b |= b >> 8
    return b & 0xFF


def parse_art_file(file):
    with open(file, 'rb') as f:
        contents = compoundfiles.CompoundFileReader(f).open('Contents')
        contents.seek(4)  # file size
        return zlib.decompress(bytes([swizzle(b) for b in contents.read()]))

.emb files are the same but the swizzle for the contents doesn't exist.

Then you'd reverse engineer the file, etc.

like image 38
Tatarize Avatar answered Sep 30 '22 10:09

Tatarize