gdsestimating / dxf-parser

A javascript parser for DXF files. It reads DXF file strings into one large javascript object with more readable properties and a more logical structure.
MIT License
452 stars 140 forks source link

Property HATCH #31

Open andrelmlins opened 6 years ago

andrelmlins commented 6 years ago

Would it be possible to read the hatch property within an entity?

bzuillsmith commented 6 years ago

Do you mean the HATCH entity? It's possible to add them, but will require quite a bit of work. HATCH entities are one of the most complex entities in the DXF spec. I'm open to pull requests for anyone who wants to work on this. Not sure when I will have time to work on this next.

kpetrow commented 3 years ago

going to upvote this.

hschmiedhofer commented 1 year ago

would be great to have this.

dlabz commented 1 year ago

Parsing the hatch patterns seems very straight-forward, as they are specified as .pat hatch files, as explained on the https://pattycake.io . All codes are available in the autocad_2012_pdf_dxf-reference_enu.pdf .

Rendering them to svg or canvas is a bit trickier, and I still need to figure out a reasonable approach to do it.

kpetrow commented 1 year ago

I ended up writing my own hatch parser, but it crashes browser frequently if trying to use canvas image with bounds inside the polygon. Maybe you could draw lines or something??

dlabz commented 1 year ago

Yeah, parsing is straight-forward. There's also this pull request from 2019. covering some of it: https://github.com/gdsestimating/dxf-parser/pull/45

There's some compatibility issue between the hatches and the browser. SVG2 planned for <hatch> and <hatchpath> elements, but seems they opted against it. Even Autodesk Forge brute-forces hatches as individual stroke lines.

I'm guessing Houdini aka CSS Painting API Worklets is the most recent initiative to bridge this gap, but support is still spotty.