microsoft / microsoft/maker.js

Unexpected output when using usePOLYLINE with DXF exporter

Open
#324 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
TypeScript
Stars
2k
Forks
302
Avg merge
21h 28m
Merged PRs (30d)
5

Description

I'm seeing an inconsistency in the output of the DXF exporter between having usePOLYLINE enabled and disabled. I'm in the process of reducing a reproducible case to the point where looking at the generated DXF text is manageable; but I thought I'd share what I have now.


To reproduce:

  1. Run the following in a Maker.js playground:
var makerjs = require('makerjs');

function polylineBug() {
  var pathData = `
    M48,30 L50,30
    M50,15 L50,20 Z
    M50,25 L55,20 L50,20 Z
    L50,30
  `;
  
  return makerjs.importer.fromSVGPathData(pathData);
}

module.exports = polylineBug;
  1. Export as a DXF via button beneath model view. Enable the Use POLYLINE option, and choose Max accuracy. (Bug appears to happen on any accuracy.)

Here's what I'm seeing in the exported DXF with POLYLINEs enabled. Note the missing segment on the left side of the triangle:
dxf with polylines

Here's a DXF of the same model, exported with Use POLYLINE disabled. The segment on the left side of the triangle is back:
dxf without polylines


Some other interesting values for pathData which do not trigger the bug:

M48,30 L50,30
M50,15 L50,20 Z
M50,20 L55,20 L50,25 Z     // reversing the direction of the problem triangle
L50,30
M48,30 L50,30
M50,15 L50,19 Z     // breaking the chain between y=19, y=20
M50,25 L55,20 L50,20 Z
L50,30

From fiddling around with values in pathData, it seems like the bug is not triggered when the chain including the segments at x = 50 is broken. (Uncertain if this would be considered a real "chain" in Maker.js's terminology – I'm realizing that I should read through the chain documentation.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Maker.js playground example and export it as DXF with Use POLYLINE enabled and disabled. Inspect the DXF exporter’s POLYLINE handling and chain processing while comparing the generated output. Done means the reproducer preserves the missing triangle segment when POLYLINE is enabled, with coverage for the reported path data.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.