Closed
Description
Hi Maker.js developers!
I try to convert an SVG with lines, circles, arcs & ellipses to a DXF.
This approach is working as long as the objects are of the same type (only lines or only arcs...). As soon as the objects are mixed, they are not properly connected and are overlapping a tiny little bit or a small cap is created. Thus, it's not a chain any more.
//case line
let lines = svg.getElementsByClassName("line")
for (let j = 0; j < lines.length; j++) {
let child = lines[j]
let childPath = "M" + child.getAttribute("x1") + " " + child.getAttribute("y1") + ", L" + child.getAttribute("x2") + " " + child.getAttribute("y1")
let svgPathData = makerjs.importer.fromSVGPathData(childPath, { bezierAccuracy: 0.0 })
let line = svgPathData.paths?.p_1
makerjs.model.addPath(model, line, "line")
}
//case semi-circle (radius x == radius y)
let semiCircles = svg.getElementsByClassName("arc")
for (let j = 0; j < semiCircles.length; j++) {
let childPath = semiCircles[j].getAttribute("d")
let svgPathData = makerjs.importer.fromSVGPathData(childPath, { bezierAccuracy: 0.0 })
let arc = svgPathData.paths?.p_1
makerjs.model.addPath(model, arc, "arc")
}
//..same for circles and ellipses
//export to dxf
let chains = makerjs.model.findChains(model)
let dxf = makerjs.exporter.toDXF(model, { usePOLYLINE: true })
If I zoom in very close it looks like this:
Does anyone have an idea how to fix this issue so that all objects are merged properly?
Metadata
Metadata
Assignees
Labels
No labels