CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
3.15k stars 289 forks source link

DXF export for sketch #1575

Closed adam-urbanczyk closed 1 month ago

adam-urbanczyk commented 5 months ago

Currently this kind of workaround is required:

s = cq.Sketch()
...

exporters.exportDXF(cq.Workplane().add(s._faces), 'out.dxf')
lenianiva commented 2 months ago

Is this a hack? Why not just add this as a function to Sketch?

Edit: I just tried it and it doesn't work for all sketches. If there are disconnected edges it could not handle them. The following could probably work. I tried it on some of my sketches.

def sketchToDxf(sketch, **kwargs):
    w = (
        cq.Workplane()
        .add(sketch._faces)
        .add(sketch._wires)
        .add(sketch._edges)
    )
    cq.exporters.exportDXF(w, **kwargs)