maker.js icon indicating copy to clipboard operation
maker.js copied to clipboard

Added lineWeight support to dxf exporter

Open xavi- opened this issue 8 months ago • 2 comments

This PR exposes the ability to change the Line Weight of lines drawn in a particular layer. This is a feature that was added in DXF R2000 and is supported by other DXF libraries. Ex: https://ezdxf.readthedocs.io/en/stable/concepts/lineweights.html

The hope was to also make the DXF exporter in closer parity with the SVG exporter, specifically in terms of strokeWidth

xavi- avatar May 27 '25 03:05 xavi-

@microsoft-github-policy-service agree

xavi- avatar May 27 '25 03:05 xavi-

Wow, thank you so much! Is this backward compatible with older DXF versions?

danmarshall avatar Jun 10 '25 22:06 danmarshall

To be honest, I'm not sure. According to a gemini result, DXF R2000 came out in March 1999, though it might be confusing DXF R2000 with AutoCAD 2000 and/or DWG 2000 (or maybe they all came out at the same time! I'm not sure). In either case, support for Line Weight seems fairly well established

Also, I think, I read some where that most DXF readers ignore codes that they don't recognize so it should be backwards compatible

xavi- avatar Jun 19 '25 14:06 xavi-

Okay a bit more research and it seems DXF AC1015 is synonymous with DXF R2000, which indeed came out in March 1999.

See https://images.autodesk.com/adsk/files/autocad_2012_pdf_dxf-reference_enu.pdf (page 11)

xavi- avatar Jun 19 '25 14:06 xavi-

Thanks for doing the research. I think then that we can remove enableLineWeight and just look for the existence of a lineWeight to add the header.

danmarshall avatar Jun 23 '25 19:06 danmarshall

Sounds good. I can make the $LWDISPLAY header always enabled. Would that make sense? (1ac2c1a)

xavi- avatar Jul 03 '25 00:07 xavi-

Looks like the DXF test is failing

danmarshall avatar Jul 03 '25 23:07 danmarshall

Should be working with latest commit

xavi- avatar Jul 04 '25 00:07 xavi-

Unfortunately, I was wrong. This solution doesn't work in all viewers. In TrueviewCAD, the generated dxf file is considered invalid. The fix isn't straightforward and requires very invasive changes. I'm going to close this PR.

xavi- avatar Jul 17 '25 04:07 xavi-

Your diligence is appreciated, thanks!

danmarshall avatar Jul 17 '25 20:07 danmarshall