A r/SolidWorks thread from last week: user exports a sheet metal part to DXF, sends it to the laser shop, gets a call saying the file is corrupt. The file is 20MB for a bracket with three bends. The shop’s nesting software chokes loading it. The user is exporting from the drawing, not from the part.

This is the most common DXF export mistake in SolidWorks, and it is invisible until something downstream breaks.

There are two completely separate DXF export paths

SolidWorks exposes DXF export from two different document types, and they produce fundamentally different output:

Path 1 — Drawing export (File > Save As > DXF from a .slddrw file): Exports the drawing sheet as a DXF. Every drawing view is a separate projection of all model edges into 2D. Annotations, dimensions, notes, title block borders, section lines, hatch patterns, and BOM tables are all written as DXF entities. For a typical four-view drawing of a sheet metal bracket, this means thousands of redundant edge entities — each view independently re-projects every visible edge — plus dimension geometry on top.

Path 2 — Flat pattern export (File > Save As > DXF or Export > DXF/DWG from a .sldprt file with sheet metal features): Exports only the flat pattern outline of the sheet metal body. The output is the unfolded perimeter, hole cutouts, bend lines, and (if configured) forming tool marks. A typical bracket produces a DXF with 50–200 entities.

The same physical part. Two numbers from the same “Save As > DXF” menu item. The difference is which file type is active.

What is inside a drawing DXF

Open a drawing DXF in any text editor — it is plain ASCII. The structure is:

0
SECTION
2
ENTITIES
...
0
LINE
8
0
10
12.5340
...

For a four-view drawing, count the LINE, ARC, POLYLINE, ATTRIB, INSERT, and TEXT entity blocks. On a moderately complex part you will find:

  • 3,000–15,000 LINE entities (visible edges, hidden lines if enabled, annotation leaders)
  • 500–2,000 LWPOLYLINE or POLYLINE entities (title block borders, hatch boundaries)
  • Hundreds of DIMENSION entities (each expands into separate geometry: two witness lines, one dimension line, two arrowhead blocks, text, tolerance text)
  • HATCH entities with hundreds of boundary segments for section view fills
  • INSERT entities referencing BLOCK definitions (drawing symbols, tolerancing callouts)

Total: a part with one flat face can easily produce 5,000–50,000 DXF entities in a drawing export. At ~80 bytes per entity, that is 400KB to 4MB. Add hatch fills on a section view and you breach 20MB.

What is inside a flat pattern DXF

The flat pattern export skips the drawing layer entirely. SolidWorks calls IPartDoc::ExportToDWG2 with the Action parameter set to swExportToDWG_ExportSheetMetal (integer value 2). This mode unfoldes the sheet metal body and writes:

  • One LWPOLYLINE per outer contour loop
  • One LWPOLYLINE or ARC per hole
  • LINE or ARC entities for bend lines (if the bend line layer option is enabled in the bitmask)
  • Optional: etching lines from sketch geometry on named layers

For a bracket with three bends and four holes: roughly 50–150 entities total. File size: 30–120 KB.

This output is exactly what nesting software expects. There is no annotation noise, no dimension geometry, no hatch. The CAM toolpath operates on the contour polylines directly.

Why “Save As > DXF” from the part also works (and when it doesn’t)

If you right-click a sheet metal part in Windows Explorer and choose “Open With > SOLIDWORKS”, then do File > Save As > DXF from the part document, SOLIDWORKS detects the active flat pattern and invokes the flat pattern path automatically. This is the same code path as the right-click export from the FeatureManager.

Where it breaks down:

Non-sheet-metal parts. If the part has no Sheet-Metal feature, SolidWorks uses Path 1 (viewport projection) instead. The same File > Save As > DXF menu item switches behaviour based on the feature tree. If your part was created as a solid extrusion and converted to sheet metal via Convert to Sheet Metal but has an unsolved flat pattern, it may also fall through to the projection path.

Multi-body parts. ExportToDWG2 with sheet metal mode exports the first active sheet metal body by default. If your part has three sheet metal bodies with separate flat patterns, the default export silently picks one. You need either ICadBody::ExportToDWG2 per body, or a batch macro that iterates IBody2 members and exports each.

Drawings with flat pattern views. If your drawing has a dedicated flat pattern view (inserted via the Flat Pattern option in the View Palette), and you export that drawing to DXF, the output still goes through Path 1 — you get the drawing DXF, not the part’s flat pattern export. The flat pattern view in a drawing is just a projected view with the flat pattern feature state; it is not the same as calling ExportToDWG2 on the part.

How to check which path your macro is using

Search your macro or add-in code for the export call:

' Path 1 — drawing projection (will be large):
swModel.Extension.SaveAs3 filePath, 0, 0, Nothing, Nothing, errors, warnings

' Path 2 — flat pattern (what you want for laser cutting):
swPart.ExportToDWG2 filePath, swDrwDoc, False, bSuccess, Nothing, Nothing, Nothing, False, pSheetMetalOpts

The distinguishing marker is ExportToDWG2 versus SaveAs3. If you see SaveAs3 in sheet metal batch code, the output will be the drawing-style projection even on a part document if the active view direction is not perpendicular to the flat face.

For the full breakdown of what Action=0 versus Action=2 produces and why the alignment array behaviour differs between them, see SOLIDWORKS API DXF Export: Why VBA and Manual Export Differ.

The entity bitmask controls what appears in Path 2

Even on the correct flat pattern export path, the output depends on the SheetMetalOptions_e bitmask passed to ExportToDWG2. The default API value is 1 (geometry only). Bend lines require bit 2 (swExportFlatPatternOption_IncludeBendLines). Sketch geometry on named layers requires bit 8. Hidden bodies in the active configuration are excluded by default — bit 4 includes them.

If your flat pattern DXF is missing bend lines, the bitmask is the first thing to check. SolidWorks DXF Export Settings — Entity Types and Options documents every bit and what it produces.

File size as a quick sanity check

Before sending any DXF to a laser shop or nesting software, check the file size:

Part complexityExpected flat pattern DXFLikely drawing DXF
Simple bracket (3 bends, 4 holes)30–80 KB2–8 MB
Enclosure (10 bends, 20 holes)80–200 KB5–20 MB
Complex weldment flat part150–400 KB10–50 MB

If a DXF for a simple part exceeds 500 KB, you are almost certainly on Path 1. Open the file in a text editor and search for DIMENSION entities — if you find any, the file came from a drawing export.

Batch workflows

If you batch export flat patterns from a SolidWorks assembly, the batch code should open each referenced part file directly and call ExportToDWG2, not open the corresponding drawing and call SaveAs3. This also avoids the need for a valid drawing to exist for every part — parts without associated drawings are skipped in a drawing-first workflow, while a part-first workflow processes every sheet metal part regardless.

CadShift uses ExportToDWG2 with the sheet metal action throughout its batch export pipeline. The result is that a 200-part assembly produces DXF files that sum to 5–20 MB total, rather than 200 individual drawing DXFs that total 2–4 GB. How to batch export DXF files from a SolidWorks assembly covers the part-first batch approach with full assembly traversal.

For DXF to CNC nesting workflows, file size matters not just for storage but for nesting software performance. Most nesting applications load all parts into memory before solving the layout. A 20 MB drawing DXF uses roughly 400x more memory during nesting than an equivalent 50 KB flat pattern DXF.