Layer-by-layer manufacturing covers more territory than most engineers realize. Laminated object manufacturing (LOM), sliced tooling blocks for composite layup, sectioned mold plates for waterjet stacking, large-format CNC where layers are cut and stacked — all of these need DXFs at specific Z heights. SolidWorks doesn’t have a “slice and export” button. But there are three workable approaches, and one of them scales with an API.
The problem in concrete terms
A customer operates a layer-by-layer cutting machine: it takes DXF profiles at fixed Z-height increments (say, 3mm steps), cuts each layer from sheet stock, and stacks them to build up a 3D form. Your job is to deliver fifty DXF files, each representing the cross-section of the part at a different height.
The Reddit thread that surfaced this problem had two competing suggestions: split the part into bodies via Split feature + assembly + drawings, or use section views on multiple drawing sheets. Both work. Neither is fast. The third approach — API automation — works for anything beyond one-off jobs.
Approach 1: Split feature + per-body DXF
This is the manual approach the community reaches for first.
Steps:
- Create a series of reference planes at each target Z height (e.g., Plane1 at Z=3mm, Plane2 at Z=6mm, up to your total height)
- Use Insert → Features → Split with all planes selected to divide the part into one body per layer
- Save each body as an individual part via Insert → Part or via the multibody split workflow
- Create a drawing for each saved part, add a front view (which shows the flat cross-section)
- Export each sheet as DXF
This works for small layer counts. For 20+ layers, creating 20+ planes, splitting, saving 20+ parts, and drawing 20+ single-view drawings is hours of manual work that breaks whenever the parent part changes.
The Split feature also has a geometry constraint: it produces volume bodies, not surface cross-sections. Each body is a 3mm-thick slice, not a 2D profile. To export the actual cross-sectional outline, you need to extract the top face of each body — which can be done but requires an extra step (right-click face → Save As Surface, or use a face loop API call).
Approach 2: Section views on multiple drawing sheets
This is the approach that produces clean 2D cross-sections without creating intermediate solid bodies.
Steps:
- Create a base part drawing with one sheet per layer
- On each sheet, insert a Section View with its cutting plane at the target Z height
- For each section view, set the Display Style to “Edges Only” with no fill
- Export the drawing via File → Save As → DXF with multi-sheet enabled
The section view in a SolidWorks drawing is exactly the cross-section you want — it shows only the cut edges at that plane, no projected geometry from adjacent faces. The DXF output from a section view gives you the closed loop profile that a laser or waterjet machine can cut directly.
Limitation: section views in drawings are parametric with the model but not with the cutting plane position. You can’t script “create 50 section views at Z=3,6,9…150mm” through the drawing UI. This still requires manual sheet creation for large layer counts, though it’s faster than the Split approach per layer.
For models that change shape significantly between layers, section views also pick up internal section cross-hatching that needs to be suppressed. In the view properties, set Section line display to show only the cut edges, not the full model projection.
Approach 3: API automation with plane-based body slicing
For large layer counts or parametric workflows (the part dimensions change, the layer thickness changes, or you need to re-export regularly), the API approach is the only viable path.
The strategy: create offset planes programmatically, extract face loop geometry at each plane, and write the loop as a DXF polyline.
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.IO;
public static void ExportLayerDxfs(PartDoc part, double startZ, double endZ,
double stepMm, string outputFolder)
{
ModelDoc2 doc = (ModelDoc2)part;
FeatureManager featMgr = doc.FeatureManager;
double stepMeters = stepMm / 1000.0;
int layerIndex = 0;
for (double z = startZ; z <= endZ; z += stepMeters)
{
// Create an offset plane at this Z height
// Reference plane: Top plane (XY plane at Z=0)
Feature topPlane = GetTopPlane(doc);
object[] planes = featMgr.InsertRefPlane(
(int)swRefPlaneReferenceConstraints_e.swRefPlaneReferenceConstraint_Distance,
z,
0, 0, 0, 0);
RefPlane refPlane = (RefPlane)planes[0];
// Create a section view on this plane to get the cut geometry
// For direct loop extraction, use IBody2.GetFaceCount and face loops
object bodies = ((object[])part.GetBodies2((int)swBodyType_e.swSolidBody, true));
string layerPath = Path.Combine(outputFolder, $"layer_{layerIndex:D03}_z{z*1000:F1}mm.dxf");
ExportSectionAsDxf(doc, refPlane, layerPath);
// Clean up the temporary plane
doc.Extension.SelectByID2(((Feature)refPlane).Name, "PLANE", 0, 0, 0, false, 0, null, 0);
doc.Extension.DeleteSelection2((int)swDeleteSelectionOptions_e.swDelete_Absorbed);
layerIndex++;
}
}
The ExportSectionAsDxf method uses the drawing-based section view export, which is the most reliable way to get clean closed-loop geometry:
private static void ExportSectionAsDxf(ModelDoc2 partDoc, RefPlane sectionPlane, string outputPath)
{
// Create a temporary drawing with a section view
DrawingDoc drawing = (DrawingDoc)swApp.NewDocument(
drawingTemplatePath, (int)swDwgPaperSizes_e.swDwgPaperA4size, 0, 0);
ModelDoc2 drawDoc = (ModelDoc2)drawing;
Sheet activeSheet = drawing.GetCurrentSheet();
// Insert a model view (any orientation — we'll create the section from it)
drawing.CreateDrawViewFromModelView3(
partDoc.GetPathName(), "*Front", 0.15, 0.15, 0);
// Insert section view cut at our plane
// This requires mapping the plane to a drawing cut line — complex but doable via
// IDrawingDoc.InsertSectionView or IDrawingDoc.InsertModel3in1
// Simpler shortcut: save the drawing sheet as DXF
drawDoc.Extension.SaveAs(outputPath, 0, (int)swSaveAsOptions_e.swSaveAsOptions_Silent,
null, ref errors, ref warnings);
swApp.CloseDoc(drawDoc.GetTitle());
}
For production use, the drawing-creation-per-layer approach is slow (each drawing document takes 200-500ms to create). A faster alternative: use IBody2 face extraction to get the edge loops at the section plane without creating drawings at all. This requires using IMathTransform to project 3D edges onto the section plane and writing the result as a DXF LWPOLYLINE entity manually.
What the geometry looks like
A section DXF from a closed solid body at a given Z height contains:
- Outer profile: the exterior boundary of the cross-section as a closed polyline or set of arcs
- Holes: if the part has through-holes, they appear as inner closed loops (islands)
- No fill: it’s purely the edge geometry, which is what cutting machines expect
For laminated mold tooling, you typically want one DXF per layer with all loops — outer boundary plus any pockets or holes — on the same DXF layer. For selective laser sintering simulation or material deposition profiling, you may want outer boundary and inner islands on separate DXF layers for different process instructions.
Connection to multi-body DXF workflows
This slicing workflow is a variant of the multi-body DXF problem. The difference: in standard multi-body DXF export, each body is a discrete part with its own flat orientation. In layer-based export, all bodies (layers) share the same X/Y orientation — only their Z position changes.
That shared orientation is actually simpler to handle at the API level, since you don’t need to compute per-body rotation matrices. Every slice exports in the global XY plane, at the same scale, with only the profile geometry changing.
For workflows where the part geometry is complex (non-uniform layer thickness, tapered walls, elliptical cross-sections that change size at each height), the section view approach is more reliable than reconstructing loops manually. SolidWorks’ drawing engine handles the edge projection and closure correctly in cases where manual face-loop traversal would produce open or self-intersecting polylines.
When CadShift helps
CadShift’s batch export works across multiple bodies in a single part, which covers the Split-based approach. If you’ve used Insert → Features → Split to create one body per layer, CadShift exports each body to its own DXF with consistent settings, layer mapping, and naming conventions — without requiring 50 individual Save As operations.
For the section-view approach, the workflow remains drawing-based and falls outside CadShift’s current flat-pattern scope. But for teams whose parts decompose naturally into sheet-metal layers (rather than arbitrary 3D cross-sections), the flat pattern route is cleaner: each “layer” is a real sheet metal flat pattern, and batch export just works.
Takeaways
- Small layer counts (< 10): Section views on drawing sheets is the fastest approach — clean 2D profiles, parametric with the model, no intermediate bodies required.
- Large layer counts or parametric workflows: API automation is the only scalable path. Create planes, extract geometry, write DXFs in a loop.
- When the part is naturally layered (e.g., sheet metal stack or laminated tooling): Model each layer as a discrete body, use multi-body batch export to generate all DXFs in one operation.
- Geometry output: Section DXFs contain closed loops with no fill. Outer boundary and inner islands (holes, pockets) appear as separate loops. Most cutting machines read these correctly; waterjet controllers may need explicit lead-in geometry added per layer.
- Temporary plane management: If you create reference planes programmatically for each Z height, delete them after export. 50 extra planes left in the feature tree will slow rebuild significantly.
For teams running this workflow regularly against changing designs, the investment in the API approach pays off quickly. The manual paths — whether split bodies or drawing sheets — break on every significant model change and require the same multi-hour repetition each time.