8000 Added lineWeight support to dxf exporter by xavi- · Pull Request #624 · microsoft/maker.js · GitHub
[go: up one dir, main page]

Skip to content

Conversation

xavi-
Copy link
Contributor
@xavi- xavi- commented May 27, 2025

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-
Copy link
Contributor Author
xavi- commented May 27, 2025

@microsoft-github-policy-service agree

@danmarshall
Copy link
Contributor

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

@xavi-
Copy link
Contributor Author
xavi- commented Jun 19, 2025

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-
Copy link
Contributor Author
xavi- commented Jun 19, 2025

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)

@danmarshall
Copy link
Contributor

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.

@xavi-
Copy link
Contributor Author
xavi- commented Jul 3, 2025
8000

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

@danmarshall
Copy link
Contributor

Looks like the DXF test is failing

@xavi-
Copy link
Contributor Author
xavi- commented Jul 4, 2025

Should be working with latest commit


map["POLYLINE"] = function (polyline: DxfParser.EntityPOLYLINE) {
append("0", "POLYLINE",
"370", "-1", // Set line weight to -1 to use the layer's line weight
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for these 3 "370"s - can we inject only if a layer lineweight exists?

@xavi-
Copy link
Contributor Author
xavi- commented Jul 17, 2025

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- xavi- closed this Jul 17, 2025
@danmarshall
Copy link
Contributor

Your diligence is appreciated, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0