Skip to content

Issue converting different objects to a closed dxf #480

Closed
@tabeaeggler

Description

@tabeaeggler

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:
issue dxf export

Does anyone have an idea how to fix this issue so that all objects are merged properly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions