EmbroidePy / pyembroidery

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

Suggested method to read Punto PDC format #168

Open marshallapparalautomation opened 7 months ago

marshallapparalautomation commented 7 months ago

Been following your library and how people are using it for a while. Big fan!!

Can you suggest on a method I could use to use the tool to read Punto PDC format? I've tried analyzing the file and different methods to read/write it. Attached is an example file. Im close to understanding the basis for converting files but any advice is appreciated.

example.pdc.zip

tatarize commented 7 months ago

This file format doesn't appear to natively be an embroidery format but a working file format for Punto.

The tags used are a nested tree a bit like really weak XML where the open tags are all prefixed B_ and the ending tags are flagged E_ for begin and end. So it opens up giving the PDOC, then says the Version is 190. Gives the document frame. Then we get a Doc7. But, then, it gives the PESStreamDataTag. So this is effectively going to be the PES file loaded given in an ascii converted format. It looks like ascii hex values. Weirdly rather than something like a PEC block this contains an XML Apple PropertyList file.

There's a bunch more internal stuff and then several binary B_SECT4 block. This does not appear to contain embroidery either. Though it has a 5 byte long code with heavy repetition.

This is not an embroidery file. It's a file used by the embroidery program to store internal structures to that program. These are going to be higher level structures so things like here's this vector shape that needs a fill stitch which would be produced later.

marshallapparalautomation commented 7 months ago

Thank you for your response.

I agree. I was able to convert a middle block to some crazy apple file properties. I have to figure out a way to extract colors which seems easy enough and have dst files. I have to save out pdfs of the info sheet typical showing stitch count, preview of design and thread color order but would prefer to save files in more friendly way retaining the thread colors. Seems like dst doesn't

Seems like my options are limited to automation tricks using the Punto ui at most since the dst files don't retain the thread colors.

Thanks again

tatarize commented 7 months ago

There's more than a few files that can and do save out the colors. There's also a rarely used extended version of dst which will write out the threads. It's unclear whether many embroidery machines would throw an issue with this. But, if you save version="extended" it would actually preserve the thread colors.

Largely the lack of color saving has to do with the fact that embroidery formats are intended for machines so they only have things the machine needs to run. So it doesn't usually contain the colors of the threads since that's mostly unneeded for the device. It depends a lot embroidery machine and what formats the embroidery commands can use.

It depends a lot on what he files will be used for and on what machines. PESV6 will save out the full color information. The CSV will save things losslessly though only really for human readers and pyembroidery modules for loading. The pdoc format though, is probably not the right answer.

Really if you're wanting to preserve info, you're better off probably rolling up your own format or something. Or seeing what other formats Punto exports, some will often save that info especially when the embroiderry machines around when that format came around would have a color screen and maybe preview the project.