Nº 04Tools / Contour checker

DXF, SVG and STEP contour checker

Find the open contours, gaps, doubled lines, crossings and tiny edges in a DXF, SVG, planar STEP or BREP drawing, repair them with planex2d's defeaturing, and get closed contours for a laser cutter or watertight faces for a mesher, with the cut length and the number of pierces. planex2d checks the file in this tab, running on Pyodide/ngapp. Nothing is uploaded.

No file
Save as

Viewing options

iMarks gaps, tiny edges and small faces, with the limits below. Off, ends close to each other count as open ends and nothing is marked for its size.

Repair

iRemoves edges that touch no other edge at either end, such as a center line on its own layer.
iReplaces chains of short edges, as in a tessellated outline, by arcs, or by lines where they are straight. A fit that strays further than its tolerance is rejected.
iCloses small gaps and removes short edges and small faces, with the limits below. Off, only gaps and edges below 1e-7 m, planex2d's defaults, are cleaned up.
Merge collinear segmentsiTwo lines that meet at a vertex become one if the vertex lies within this distance of the line through their far ends.
m

Result

LayerClosedOpenLength

Open a DXF, SVG, STEP or BREP file, or a sample, to check it.

Drop a DXF, SVG, STEP or BREP file onto the sheet, or open a sample below. The sliders repair it live; hover over an edge or a mark to see what it is, and click a legend entry to show or hide it. The repaired drawing saves in the unit of the file.

Examples

Try a sample file

Each one opens in the checker above. Download them to check the same files with planex2d in Python.

  • Fig. 1DXF

    Traced plate

    A plate with a bore and a center line, its outline open by a gap of 0.02 mm, one side drawn twice, a stray line and a tiny edge.

    Download
  • Fig. 2DXF

    Tessellated bracket

    Rounded corners, a bore and a slot, every arc written as short straight segments. Fit arcs turns them back into arcs.

    Download
  • Fig. 3DXF

    Tessellated flange

    Six lobes and seven holes in 1,249 straight segments, with a center line on its own layer.

    Download
Reference

What the checker finds

The checker finds the problems in the drawing as it was made, then repairs a copy with planex2d's defeaturing.

A laser, waterjet or plasma cutter follows the contours of a drawing, and its software needs every contour closed. An outline that misses its own start by a hundredth of a millimeter has no inside, a line drawn twice is cut twice, and a stray fragment costs a pierce of its own. A mesher for a simulation needs the same and more: faces that close exactly, edges shared exactly between neighboring faces, and no tiny edges or nearly collinear pieces, which force needlessly small elements. Drawings exported from other programs, traced from images or put together from several sources break these rules in ways that do not show on screen. The checker marks each problem where it is and repairs the drawing, for a cutter or for a mesher.

The checks

The legend of the drawing lists every kind of problem with the number left in the repaired drawing, so the numbers drop as the repair settings rise; the status line also gives how many the drawing had as drawn. A click on a legend entry shows or hides its marks, and the edge ends and the drawing as it was are entries there too. Mark small features sets when two ends count as a gap, an edge as tiny and a face as small; switched off, none of the three is marked.

  • An open end is an end of an edge that no other end meets.
  • A gap is two ends closer than the gap distance that do not meet. Farther apart, they are two open ends.
  • A crossing is two edges that meet where not both of them end, such as a center line across an outline or a line ending on another one, or a point where three or more edges end.
  • A doubled line is two edges that share a stretch, which a laser would cut twice.
  • A tiny edge is shorter than the tiny limit.
  • A small face has less area than the face limit.

The repair

Layer by layer, ends closer than the gap closing distance are joined, edges are cut where they cross, and a doubled stretch is kept once. planex2d's Simplify then removes edges below the limit, merges lines that are nearly collinear, removes free edges, which touch no other edge at either end, and fits arcs to chains of short edges where that is switched on. Every fit is checked against the edges it replaces and rejected if it strays further than its tolerance. The closed contours of each layer become faces with the contours inside them as holes, and the faces of all layers are glued into one shape, in which small faces are removed or merged into the neighbor they share the longest boundary with.

Cut length and pierces

The cut length is the length of every edge after the repair, and every contour, closed or open, needs one pierce. The table gives both per layer, since a layer of center lines or engraving is usually not cut through.

For meshing

A mesher needs closed faces that share their edges exactly, and tiny edges, nearly collinear pieces and tessellated curves make a mesh needlessly fine. The STEP and BREP files hold the repaired faces glued into one shape. See Defeaturing and simplification in the docs for the steps in Python.

Reading as drawn

A DXF file is read entity by entity, as it was drawn, so that nothing is joined or cut before the check. SVG, STEP and BREP files are read by planex2d's readers, which already join the ends that meet and cut crossing edges where they cross. In these files the check finds open ends, gaps and tiny edges, but no crossings or doubled lines.

Units

The checker works in the unit the file names, and the sliders, the hover texts and the result show it. A DXF file names its unit in its header, an SVG file in its width and height, and a STEP file in the file itself. A file that names none, such as every BREP file, is taken in meters, the SI unit, and so are the sliders before a file is open. The settings are kept in SI units, so they keep their size when a file in another unit is opened. The repaired drawing is saved in the file's unit, or in millimeters where a format cannot name it.

Methodology

How the checker works

A small page around the planex2d Python library. It runs the same code you get with pip install planex2d, compiled to WebAssembly and loaded with Pyodide/ngapp.

  1. Load

    The page loads Python and planex2d into this tab. Your browser keeps both in its cache, so later visits start faster.

  2. Read

    The browser reads the file from your disk into memory. No request carries it to a server.

  3. Check

    planex2d's Diagnose finds the open ends, gaps, crossings and doubled lines, and the checker adds the tiny edges and small faces.

  4. Repair

    A copy of the drawing is repaired with the settings on the left and checked again, at every change of a setting.

Supported files

FormatExtensionsNotes
DXF.dxfRead entity by entity as drawn, by layer, so every check applies. Saved by layer.
SVG.svgRead joined and cut, so crossings and doubled lines are not found. See SVG.
STEP.step .stpPlanar parts, read joined and cut. Saved as faces glued into one shape. See STEP and BREP.
BREP.brepPlanar parts, taken in meters, since BREP names no unit.

Run it in Python

The checks and the repair are planex2d's own calls. Install it and see Defeaturing and simplification and Geometry checks in the docs. The example finds the gap of the traced plate sample, closes it and measures the repaired plate.

$ pip install planex2d
import planex as px

wires = px.FromDXF("traced-plate.dxf", scale=1, layers=["0"])
found = px.QuickSketch(wires, copy=True).Diagnose(gap=0.05)
print({kind: len(faults) for kind, faults in found.items()})
fixed = [w.Simplified(close_gaps_smaller=0.05, remove_edges_smaller=0.001) for w in px.Wires(wires, 0.05)]
plate = px.Face([w for w in fixed if w.IsClosed()])
print("area", plate.mass)

Privacy

NOTE

Nothing is uploaded. The file is checked and repaired in this tab and is gone when you close it. Python, planex2d and its packages come from public package servers (jsDelivr and PyPI). See the privacy notice.

Limits

  • This tool reads and writes planar STEP and BREP files only.
  • Text, dimensions, hatches and images are not read; the checker looks at the geometry only.
  • Pierces count the contours; lead-ins and the order of the cuts are not planned.
  • In the browser, planex2d runs in one thread, so large drawings take longer than in Python on your machine.
  • A file that fails? Open an issue on GitHub and attach the file if you can.
Questions

Questions and answers

Is my file uploaded?

No. The file is read, checked and repaired in this browser tab by planex2d, running on Pyodide/ngapp, and is gone when you close the tab. Python and its packages come from jsDelivr and PyPI; your file is never sent anywhere.

Why does a laser cutter reject my DXF file?

Most often because a contour does not close: two ends miss each other by a hair, a line is drawn twice, or a short stray edge is left over. The checker marks each of these where it is, and the repaired file closes the contours and keeps every line once.

How small a gap counts?

Two ends count as a gap when they are closer than the gap distance, which starts at a thousandth of the drawing's larger side; farther apart, they are two open ends. The repair closes gaps up to its own distance.

How are the cut length and the pierces counted?

The cut length is the length of every edge after the repair, and each contour, closed or open, counts as one pierce. The table gives both per layer, so that a layer of center lines or engraving can be left out.

Can I prepare geometry for meshing with it?

Yes. With small edges removed, nearly collinear lines merged and arcs fitted to tessellated curves, the repaired drawing saves as STEP or BREP with faces that share their edges, ready for a mesher.

Which files can I check?

DXF files completely. SVG, planar STEP and BREP files are joined and cut by their readers before the check, so for them the checker finds open ends, gaps and tiny edges, but no crossings or doubled lines.

More tools

Other tools on planex2d.org

Every tool runs on the planex2d library, in your browser.

  • Viewer

    DXF, SVG, planar STEP and BREP files shown layer by layer, read by planex2d.

  • Converters

    Many DXF, SVG, STEP and BREP files in, one format out, all saved at once.

  • Calculator

    Area, centroid, second moments and section moduli of a drawing, and the mass of a sheet part.

  • Nesting

    Plies and flat parts placed on a roll for the shortest length, with the fiber direction kept.

  • Playground

    planex2d code in the browser, beside what it prints and draws, shared as a link that carries the code.

The planex2d documentation shows the library behind the tools, and the homepage lists everything on planex2d.org.