Drawing Cleanup in AutoCAD Map 3D Explained

Drawing Cleanup in AutoCAD Map 3D Explained

The drawing that taught me to respect cleanup was a street network, digitized over two summers by students from a printed map. When the city tried to build a network from it, the topology tool produced an error report with 3,100 entries. We opened the drawing and zoomed in on the first error. Two streets that obviously met at a junction ended 4 centimeters apart. We zoomed in on the second. A street that ran past the junction by 30 centimeters. The third was a street that was drawn twice, one line exactly over the other. The fourth was a tiny line, 2 millimeters long, hidden under a label. By the tenth error, I understood that I wasn’t looking at 3,100 problems. I was looking at four kinds of problem, repeated 3,100 times, which is precisely the condition under which a tool can help.

That tool is Drawing Cleanup in AutoCAD Map 3D. It’s a rule-driven system for finding and fixing the geometric faults that stop drawings from behaving as data: duplicate objects, tiny fragments, gaps, overshoots, crossings without nodes, pseudo-nodes and dangling ends. Used well, it can turn a drawing that can’t support a network or a polygon topology into one that can, in minutes rather than weeks. Used carelessly, it can quietly destroy real features. The difference lies in understanding what each cleanup action does, in what order to run them, how to choose tolerances and how to check the result.

In this guide I’ll explain the problems that cleanup solves, each action in the toolkit, a safe workflow, how to choose tolerances from your data, how to prepare drawings for different purposes (networks, polygons, conversion), what the tool can’t do, and equivalent approaches in QGIS and with scripts. It is part of our Autodesk series. For the program itself, see AutoCAD Map 3D Beginner’s Guide, and for the analysis that depends on clean data, Spatial Analysis in AutoCAD Map 3D: Topology, Queries and Overlays.

A note on facts: the names, order and options of the cleanup actions vary between Map 3D versions. I describe the typical set and the principles. Check your version’s documentation and dialog.

Illustration: Cleanup repairs gaps, overlaps, dangling lines and slivers so a drawing can become a usable GIS dataset.
Cleanup repairs gaps, overlaps, dangling lines and slivers so a drawing can become a usable GIS dataset.

What Is “Clean” Data?

A drawing is clean when its geometry is fit for the purpose you have in mind. That depends on the purpose.

PurposeWhat “clean” means
PlottingIt looks right at the plotted scale. Tiny gaps and duplicates are invisible and harmless
A network (pipes, roads)Lines connect exactly at junctions. No duplicates. No stray fragments. Directions known
Polygons (parcels, zones)Boundaries close. Neighbors share edges. No gaps or overlaps
Conversion to GISClean by the above, plus consistent layers, and attributes ready to be attached
QuantitiesNo double-counted objects. Lengths and areas are real

Plotting standards are the lowest bar. Most drawings were made to meet it. The jump from “looks right” to “behaves right” is what cleanup does. See Fixing Topology Errors and Overlaps for the general theory, and CAD vs. GIS: What Is the Difference and When to Use Each? for why drawings and datasets differ.


The Problems Cleanup Solves

Each problem is common, has a distinct signature, and calls for a distinct remedy.

1. Duplicate objects

Two objects occupy the same place, exactly or almost exactly. Causes: copy-paste accidents, merged drawings, two people drawing the same feature. Effects: double-counted lengths, topology errors, confusing queries.

2. Very short objects

Tiny line fragments, often under a few millimeters or centimeters, left over from editing or created by breaking objects. They’re invisible at plot scale, and they break networks, because each fragment has its own endpoints.

3. Zero-length objects

Objects with no length at all, such as a polyline whose points are all in the same place. They have no geometric meaning, and can cause errors.

4. Gaps (undershoots)

A line that ends before reaching the line it should connect to. The most common cause of broken networks.

5. Overshoots (dangles)

A line that extends past its junction. It leaves a short dangling stub. In a network, the stub is a spurious dead end.

6. Clustered nodes

Several endpoints that should be one junction, spread over a small area because each line was drawn separately. The junction is a cloud of nearby points, not a single node.

7. Crossings without nodes

Two lines cross, but neither has a vertex at the crossing. Visually, it’s a junction. Topologically, it isn’t. (Sometimes, it is correct: a bridge, a pipe crossing over another.)

8. Pseudo-nodes

A node where exactly two lines meet end to end, with no reason for a break. Often harmless, but it makes a road or a pipe into two features when you need one. (Sometimes meaningful, when attributes change at that point.)

9. Dangling objects

Short lines hanging off a network that go nowhere, sometimes drafting remnants, sometimes genuine dead ends. Distinguish them.

10. Over-detailed polylines

Polylines with far more vertices than their accuracy justifies, from digitizing or conversion, which inflate file size and slow analysis.

The cleanup tools have a corresponding action for each of these.


The Cleanup Actions

Map 3D’s Drawing Cleanup tool (the MAPCLEAN command, found in the Map tools on the ribbon in most versions) offers a set of actions, which you select, order and configure. The set typically includes the following. Names may differ slightly in your version.

ActionWhat it doesMain parameter
Erase zero length objectsRemoves objects with no lengthNone (or a tiny tolerance)
Delete duplicatesRemoves objects that lie on top of each otherTolerance for “same place”
Erase short objectsRemoves objects shorter than a given lengthMinimum length
Snap clustered nodesMoves endpoints that lie close together to a single locationSnap tolerance
Break crossing objectsSplits objects where they cross, creating a node(Applies to crossings)
Extend undershootsExtends lines that stop short of another line, so they connectMaximum extension distance
Apparent intersectionCreates intersections where objects visually cross or nearly cross, including cases where one lies slightly off the otherTolerance
Dissolve pseudo nodesMerges lines that meet end to end at a node with only two linesOptions for which objects to merge
Erase dangling objectsRemoves short lines that connect at one end onlyMaximum length of a dangle
Simplify objectsReduces the number of vertices in polylines, within a toleranceTolerance

Each action works on the objects that you select for cleanup (by layer, object type or selection), and each has its own tolerance, in drawing units. That last point matters: a tolerance of 0.05 means 5 centimeters in a drawing in meters, but only 0.05 millimeters in a drawing in millimeters, and about 0.6 inches in a drawing in feet. Always confirm the units before setting tolerances.

Cleanup methods: modify or mark

Cleanup tools typically give you a choice of how to treat the results:

  • Modify the original objects: the fix is applied directly. Fast, destructive.
  • Create cleanup objects: the tool creates new objects, or markers, showing what it would change, without altering the originals. Good for review.
  • Delete original objects and replace them (for some actions).
  • Mark errors without fixing, so that you can inspect and decide.

For a first pass, prefer marking or working on a copy, and review.

Saving a cleanup profile

You can save the settings (the actions, their order and the tolerances) as a cleanup profile and reuse it. This is how you make cleanup repeatable, which matters when you have hundreds of drawings. Name profiles for their purpose and units, such as “Network_meters_5cm”. See Batch Processing DWG Files: Core Console, Scripts and FME for running them in bulk.


The Order of Operations Matters

The actions interact. Running them in the wrong order can create new problems, such as extending a line to a duplicate that was about to be deleted. A sensible order, which follows the logic of the damage:

  1. Erase zero length objects. Remove the meaningless.
  2. Delete duplicates. So that nothing is processed twice.
  3. Erase short objects (with a small, careful tolerance). Remove fragments that would create spurious nodes.
  4. Snap clustered nodes. Unify endpoints that should be a single node.
  5. Break crossing objects, and apparent intersections, where junctions should exist.
  6. Extend undershoots. Close the gaps that remain.
  7. Dissolve pseudo nodes, if you need continuous features.
  8. Erase dangling objects. Remove stubs that remain (only after the previous steps, which turn many apparent dangles into proper connections).
  9. Simplify objects, if the file is over-detailed. Last, so that earlier steps work on the full detail.

Map 3D’s dialog lets you arrange the order. Adapt it to your data, and test it on a sample. Run it twice: a second pass often finds problems that the first uncovered. Then check that a third pass finds nothing, which is the sign that the drawing has settled.


Choosing Tolerances: The Heart of the Matter

A tolerance that is too small leaves problems. One that is too large damages real features. A principled way to choose:

1. Know the accuracy of the data

If the data was digitized from a 1:1,000 map, positional accuracy is probably around a meter. A tolerance of 1 centimeter will not connect what a human drew with a 1-meter error, and a tolerance of 2 meters may merge real features. If the data comes from survey, the tolerance can be much tighter.

2. Know the smallest real feature

Your tolerance must be significantly smaller than the smallest feature that matters, such as the shortest real pipe, the narrowest real road or the smallest real parcel. If the shortest legitimate pipe is 0.8 meters, a snap tolerance of 0.5 meters is dangerous.

3. Look at the gaps

Measure the actual distances between nearby endpoints, as in the code in Spatial Analysis in AutoCAD Map 3D: Topology, Queries and Overlays. Genuine near-misses form a cluster of small values. The tolerance should be just above that cluster, with a quiet zone beyond it.

4. Use different tolerances for different actions

  • Duplicates: very small (millimeters).
  • Short objects: just above the size of the debris you see.
  • Snap: driven by the gap distribution.
  • Extend undershoots: the largest gap you are willing to bridge. This is often larger than the snap tolerance, and the riskiest.
  • Dangles: the length of a stub that is obviously noise, not a real short branch.

5. Test and review

Run on a small, representative area. Compare before and after, count the changes, and look at samples, especially the largest moves, which are the likeliest to be wrong.

A rule of thumb for review

If cleanup changes more than a small percentage of the features, something is off: the tolerance is too large, or the data has a systematic problem (such as a wrong unit) that should be solved differently.


A Safe Workflow, Step by Step

  1. Make a copy of the drawing. Never clean the only copy.
  2. Check the units and the coordinate system. Tolerances depend on them. See Coordinate Systems in AutoCAD Map 3D and Civil 3D Explained.
  3. Purge and audit the drawing, to remove unused definitions and structural problems. See Corrupted or Bloated DWG Files: Audit, Recover and Purge.
  4. Decide the purpose, and write down what clean means for it.
  5. Select the objects: only the layers and types you need. Leave dimensions, text and hatches out.
  6. Take stock: count the objects and total length by layer, so that you can compare afterwards.
  7. Choose the actions, order and tolerances, using the guidance above.
  8. Run in “mark” or review mode on a small area first, or on a copy.
  9. Review the markers or results, with zoom, at the worst places.
  10. Adjust the parameters, and rerun.
  11. Run on the whole drawing.
  12. Rerun until stable.
  13. Compare totals: objects, lengths, and sums should change only in the expected ways. Large losses of length mean over-cleaning.
  14. Build the topology as a test: the error report should be far smaller. See Spatial Analysis in AutoCAD Map 3D: Topology, Queries and Overlays.
  15. Fix what remains by hand.
  16. Save a cleanup profile, and a record of what was done: date, version, actions, tolerances, counts.

Cleaning for Specific Purposes

For a network

  • Goal: every junction is a single node, with no gaps, overshoots or duplicates.
  • Actions: zero length, duplicates, short objects, snap, break crossing (with care at overpasses), extend undershoots, dangling, and possibly dissolve pseudo nodes.
  • Extra checks: connectivity (is everything connected to the source?), direction (digitized in the flow direction), isolated fragments, loops.
  • Watch out for: genuine crossings without connection (bridges, pipes at different depths). Breaking them creates false junctions. Put such objects on separate layers, and exclude them from the crossing action.

For polygons

  • Goal: closed boundaries, shared edges, no gaps or overlaps.
  • Actions: duplicates, short objects, snap, break crossing, extend undershoots. Then create polygons from closed boundaries (or build a polygon topology), and examine the result.
  • Extra checks: every polygon has a label point or attribute, there are no unclosed rings, and the sum of the areas agrees with the total.
  • Watch out for: slivers and tiny polygons. See Fixing Topology Errors and Overlaps.

For conversion to GIS

For quantities (lengths, areas)

  • Goal: no double counting.
  • Actions: duplicates and overlaps first. Check the totals against known figures.

For cadastre

  • Goal: a seamless parcel fabric with accurate boundaries.
  • Caution: boundaries in a cadastre are legal documents. Cleanup that moves vertices by centimeters can change legal areas. Use cleanup for preparing data, and keep the survey-based boundaries as the authority. See Cadastre and Land Survey: From CAD Drawings to GIS Parcels.

What Cleanup Can’t Do

  • It can’t decide what the data means. It can connect two lines. It can’t tell you whether they should be connected. Human review remains essential.
  • It can’t fix a wrong coordinate system or wrong units. Fix those first.
  • It can’t recover missing data, such as lines that were never drawn.
  • It can’t attach attributes. It repairs geometry only.
  • It can’t distinguish genuine features from noise when they look the same: a real short pipe versus a fragment.
  • It can’t undo itself after saving, unless you made a copy.
  • It isn’t a substitute for good digitizing. The cheapest cleanup is the error that was never made: use snaps and templates. See the prevention section.

Verifying the Result

Cleanup is finished when you have evidence, not just a feeling.

  1. Counts: the number of objects, before and after, by layer. Understand every difference.
  2. Totals: total length by layer (and area for polygons). Small decreases (duplicates, shorts) are expected. Large ones are not.
  3. Topology: build the target topology, and inspect the error report.
  4. Connectivity tests: run a network trace from a known point. Does it reach everything that it should?
  5. Visual inspection: at junctions, at the worst places and at random locations.
  6. Overlay with the original: compare the cleaned drawing with the original, to see where things moved. Movements should be within the tolerance.
  7. Spot checks against survey or a reference.
  8. Documentation: the profile, the parameters and the date.

A short script that compares two exported versions of a layer:

import geopandas as gpd

before = gpd.read_file("pipes_before.gpkg")     # lines, in a projected CRS in meters
after = gpd.read_file("pipes_after.gpkg")

print("features:", len(before), "->", len(after))
print("total length (m):", round(before.length.sum(), 1), "->", round(after.length.sum(), 1))
print("shortest line (m):", round(before.length.min(), 3), "->", round(after.length.min(), 3))
print("duplicates:", before.geometry.apply(lambda g: g.wkb).duplicated().sum(),
      "->", after.geometry.apply(lambda g: g.wkb).duplicated().sum())

# Largest changes in length per feature, if you kept an ID
merged = before[["PIPE_ID", "geometry"]].merge(after[["PIPE_ID", "geometry"]], on="PIPE_ID", suffixes=("_b", "_a"))
merged["dlen"] = merged["geometry_a"].apply(lambda g: g.length) - merged["geometry_b"].apply(lambda g: g.length)
print(merged.sort_values("dlen", key=abs, ascending=False).head(10)[["PIPE_ID", "dlen"]])

See GeoPandas and Shapely: Vector Data in Python.


Equivalent Approaches Outside Map 3D

When the drawing has been converted, or if you work in open-source GIS, similar cleanup is available.

  • QGIS: the Geometry Checker and Topology Checker plugins, Processing tools such as Snap geometries to layer, Delete duplicate geometries, Split with lines, Merge lines, Extend lines and Polygonize. See Fixing Topology Errors and Overlaps.
  • GRASS tools in QGIS: the v.clean module is a specialized cleaner, with tools for breaking lines, removing duplicates, snapping, removing dangles and pseudo-nodes. See Best Free and Open-Source GIS Tools.
  • PostGIS: ST_Snap, ST_Node, ST_UnaryUnion, ST_Polygonize and ST_ReducePrecision (in recent versions). See Spatial SQL Cheat Sheet.
  • Python with Shapely: the same operations in code, which you can automate.

A small example of the “node and polygonize” pattern in Python, which builds clean polygons from messy boundary lines:

from shapely.ops import unary_union, polygonize, snap

# lines: a list of Shapely LineStrings, the boundaries digitized for a block, in meters
tolerance = 0.05

# Snap every line to the union of the others, so that near-coincident vertices coincide
reference = unary_union(lines)
snapped = [snap(line, reference, tolerance) for line in lines]

# Node the lines (split them wherever they cross or touch), then build polygons
noded = unary_union(snapped)
polygons = list(polygonize(noded))

print(len(polygons), "polygons built")

Because every polygon is built from shared, single boundaries, gaps and overlaps cannot occur between them. (The snapping tolerance is the same decision as in Map 3D, and deserves the same care.) See GeoPandas and Shapely: Vector Data in Python.


A Worked Example: Preparing a Street Network for Routing

Task: the street drawing from my opening story (digitized by students) must become a routable network.

  1. Copy the drawing. Record the units (meters) and the coordinate system. Purge unused content.
  2. Take stock: 18,400 polylines on the layer “STREETS”, total length 212 kilometers.
  3. Measure the gaps between nearby endpoints. The distribution shows a cluster below 0.25 meters (intended connections), a quiet zone from 0.25 to 2 meters, and larger gaps (real dead ends, and a few real gaps).
  4. Choose parameters: duplicates, 0.01 m. Short objects, 0.10 m. Snap clustered nodes, 0.25 m. Extend undershoots, 1.0 m. Dangling objects, 3.0 m (the shortest real cul-de-sac in the city is about 25 meters). Break crossing: yes, but only for layers other than “STREETS-BRIDGE”.
  5. Run on a test district in review mode. The review shows 412 changes, mostly small snaps. Four of the extensions join the wrong street in a dense block. Reduce the extension to 0.6 meters, and fix the four by hand.
  6. Run on the whole drawing, twice. The second pass finds 38 changes. A third pass finds none.
  7. Compare: 18,400 objects become 17,950 (duplicates and fragments). Total length changes from 212.0 to 211.2 kilometers. All the difference is explained by duplicates and fragments.
  8. Build the network topology. The error report falls from 3,100 to 61. Of those, 40 are genuine dead ends, and 21 are real gaps in the source data, which are corrected from the map.
  9. Test: a trace from the city hall reaches 99.6 percent of the network. The remaining 0.4 percent are three isolated islands, which turn out to be private roads. Mark them.
  10. Orient and attribute: street names, classes, one-way flags, as object data.
  11. Export to the routing system, with the network topology and attributes verified. See Network Analysis and Route Optimization.
  12. Save the cleanup profile and the log, and write the digitizing rules for the future.

The 3,100 apparent errors were never a 3,100-hour problem. They were four rules and a few careful hours.


Prevention: Don’t Create the Mess

  • Use object snaps when drawing: endpoint, intersection, nearest. Never draw a connection by eye.
  • Use consistent drawing standards: layers per feature type, closed polylines for areas, lines drawn in the direction of flow.
  • Draw features once. Copy-paste with care.
  • Work from templates with the right units and coordinate system.
  • Avoid unnecessary vertices.
  • Review before delivery, with a short check: zero-length and duplicate objects, closed polygons, connected networks.
  • Give contractors a delivery specification. See CAD vs. GIS: What Is the Difference and When to Use Each?
  • Audit regularly.
  • Automate checks with scripts or models. See Automating AutoCAD Map 3D: Scripts, AutoLISP and the .NET API.
  • Train editors. An hour of training in snaps saves weeks of cleanup.

Common Mistakes

  • Cleaning the only copy.
  • Not checking units and tolerances in the wrong scale.
  • One large tolerance for everything.
  • Running actions in the wrong order, or all at once without review.
  • Cleaning dimensions, text, hatches and other objects that are not geometry.
  • Breaking genuine crossings (bridges, pipes at different levels).
  • Deleting “dangles” that are real dead ends.
  • Snapping across features that are genuinely close in dense areas.
  • Skipping the verification, and trusting the tool’s silence.
  • Not rerunning until stable.
  • Cleaning legal boundaries and altering areas.
  • Treating cleanup as a one-off, and not fixing the source of the problem.
  • No record of what was done.

Final Thoughts

There is something almost meditative about cleanup. The problems are small, repetitive and unglamorous, and nobody ever thanks you for a node that is exactly where it should be. But the whole edifice of spatial analysis, every trace, every overlay, every route, stands on those small, exact connections. A drawing that can’t pass cleanup can’t be analyzed, and a team that cleans well once, and writes down how, can analyze everything it owns.

Take one drawing of your own, a network or a block of parcels, and measure its gaps. Look at the distribution, choose a tolerance with a reason and run the actions on a copy. Compare before and after. In an hour you will know more about the real quality of your data than you did in the last five years, and you will have the first line of a procedure that every colleague can reuse.

Where to go next: put your clean data to work in Spatial Analysis in AutoCAD Map 3D: Topology, Queries and Overlays, and prepare it for handover in Importing and Exporting GIS Data in AutoCAD Map 3D.

Rachid Khouri

Rachid Khouri

Rachid Khouri is a CAD, BIM and GIS professional, Autodesk Authorized Developer, trainer and technical author with more than 30 years of experience, working with AutoCAD since 1992. He founded GISauthority.com to share practical guidance on GIS and spatial technologies.