BIM

The EXTRIM command in AutoCAD: a hundred trims in two picks

The EXTRIM command in AutoCAD trims everything crossing a boundary once you pick a side. We counted objects and total length before and after, on both sides.

  • TS. Đỗ Quốc Hoàng
  • 8 min read
The same arrangement of lines twice: pick inside and the inside goes, pick outside and the outside goes Photo: Screenshot taken on AutoCAD 2027 at the Institute

You are handed a drawing full of linework and you only need what falls inside a site boundary. With the ordinary trim you pick a cutting edge and then click every stray line, a hundred times over. The EXTRIM command in AutoCAD does the same job in two picks.

This article counts the objects and their total length before and after trimming, on both sides of the boundary, on AutoCAD 2027 at the Institute. For the full set of production tools, see the advanced AutoCAD course.

What the EXTRIM command in AutoCAD is, and why the name may fail

This is an Express Tools command, not a core one. Autodesk describes it on the EXTRIM page in a single line: "Trims all objects at the cutting edge specified by a selected polyline, line, circle, arc, ellipse, text, mtext, or attribute definition."

We asked the program where its definition file lives and got C:\Program Files\Autodesk\AutoCAD 2027\Express\extrim.lsp. The command is written in AutoLISP itself, and two measurable consequences follow.

First: on a machine where Express Tools was not installed, typing the name returns Unknown command. That is why some people follow a tutorial and get nowhere.

Second, for anyone writing LISP: calling it from another routine with (command "EXTRIM" ...) does not work. The program still answers Unknown command "EXTRIM", which is exactly the line we got. The command function reaches core commands only, and this one is defined by LISP.

The EXTRIM command in AutoCAD asks two questions and stops

The prompts, copied verbatim from the 2027 release, ellipsis included.

Pick a POLYLINE, LINE, CIRCLE, ARC, ELLIPSE, IMAGE or TEXT for cutting edge...

Specify the side to trim on:

The first asks for the boundary object, and you point at one object only. The second asks which side to discard, and any point on that side will do. That is the whole interaction.

Worth noticing: the list in the prompt and the list on Autodesk's page do not match. The prompt names IMAGE, which the page does not; the page names mtext and attribute definition, which the prompt does not. Where two sources disagree, trust what the program prints while you run it.

Measured: picking inside and picking outside give opposite results

We built two identical test cases. Each has a rectangle 3000 by 2000 as the cutting edge, three lines 5000 long crossing it, one line 1800 long lying wholly inside, and one line 5000 long lying wholly outside. Five lines in all, 21800 long together.

Picking inside and picking outside Photo: Two identical test cases. Left: picked inside the rectangle, so the inside is trimmed away and stubs remain on both sides. Right: picked outside, so the outside goes and only the inside part remains. In both, lines that never cross the boundary are untouched

Then we ran the command, picking inside on the left and outside on the right, and counted by machine.

MeasurementBeforePicked insidePicked outside
Number of lines585
Total length218001280015800

Both columns can be checked by hand, which is how you know the measurement is not an accident.

Picking inside. Each crossing line is 5000 long and its share inside the rectangle is 3000, so two stubs of 1000 survive at the ends. Three lines become six, totalling 6000. Add the 1800 line wholly inside and the 5000 line wholly outside and you have 8 lines totalling 12800, exactly the figure counted.

Picking outside. This time each crossing line loses both 1000 stubs, leaving the 3000 middle. Three lines stay three, totalling 9000. Add 1800 and 5000 and you have 5 lines totalling 15800. That matches too.

Anything that never crosses the boundary object is left alone

This is where the command disappoints people, and the two rows above show it plainly.

The 1800 line sitting wholly inside the rectangle survived both runs. So did the 5000 line sitting wholly outside. Neither intersects the boundary anywhere, so there is nothing for the command to cut.

In other words it trims rather than erases. To clear everything inside or outside a boundary you still have to select the leftovers and delete them afterwards. Skipping that step leaves strays behind, and they usually surface only at plotting time.

What accumulates inside a file after tidying operations like these is covered in our article on slimming down a CAD drawing.

The three jobs where it earns its keep

This is not an everyday command. It is for the moments when there is one clear boundary and a great deal of surplus linework on one side of it.

Cutting a drawing to a site boundary. You receive a survey of the whole district and need only what lies inside the line. Draw the boundary as one closed object and trim once, instead of a few hundred clicks.

Tidying grid lines. Grid lines are drawn long so they are easy to snap to, and then they are in the way at plotting time. A rectangle around the title block makes a tidy boundary.

Trimming a background drawing. You attach an architectural plan as a background and need one zone of it; trimming the rest keeps the file light and the screen readable.

All three share one feature: the boundary is something you draw, not something that was already there. Drawing it carefully and closing it is half the work; the rest is two picks.

A fourth situation is worth naming because it is where people reach for the command and should not. Where the surplus linework is scattered on both sides of a boundary, running the command twice with opposite picks removes almost everything, including the parts you meant to keep. In that case the ordinary trim, slow as it is, remains the safer tool.

How it compares with the trim command

Both cut, but they work in quite different ways.

EXTRIMThe ordinary trim
Cutting edges selectedexactly one objectone or many
Objects to be cutnone selectedeach one picked
What decides the discardone point on that sidepicking each surplus piece
Undoone stepone step

The rule for choosing: one boundary and dozens of surplus pieces on the same side calls for EXTRIM. A handful of odds and ends, each surplus in its own way, calls for the ordinary trim, because that gives you a decision at every point.

There is one more difference that only shows up on a large drawing. The ordinary trim asks you to select the objects it may cut, so its work is bounded by that selection. This command has no such selection step and considers everything crossing the boundary, which is exactly why it is fast and exactly why it deserves a careful look at the result before you carry on.

The opposite operation, lengthening lines to a boundary, is covered in our article on the extend command. Cutting a gap in the middle of a line is covered in our article on the break command.

Is Express Tools already installed

Express Tools ships with the full AutoCAD release, but as an item that can be unticked during installation. It was present on our machine, and we checked by asking the program for the path of the command's definition file.

Three quick checks, in the order worth trying.

Type the name. A prompt asking for a cutting edge means yes; Unknown command means no.

Ask the program. Enter the one-line routine (findfile "extrim.lsp") at the command prompt. A path means it is installed, nil means it is not. That is exactly the check we used while measuring this article.

Look for the Express folder inside the AutoCAD installation directory. An extrim.lsp in it settles the question.

If it is missing, rerun the AutoCAD installer and add the Express Tools item; there is nothing to download from anywhere else. And if the name is too long to type often, give it an alias of your own, which is covered in our article on command aliases.

Three things often repeated that are not true

Often repeatedWhat we measured on the 2027 release
It wipes out everything on the side you pickLines not crossing the boundary survived on both sides
You can select several boundary objectsThe prompt takes one object only
You can call it from LISP with the command functionThe program answered Unknown command "EXTRIM"

Frequently asked questions

The program says it does not know the command.

Express Tools is not installed. Rerun the AutoCAD installer and add that item; nothing needs downloading from elsewhere.

What can serve as the cutting edge?

The 2027 prompt names polyline, line, circle, arc, ellipse, image and text. Autodesk's page adds mtext and attribute definition.

Why are there still lines left on the side I picked?

Because they never cross the boundary. We measured it: both the line wholly inside and the line wholly outside survived. Select and delete those separately.

What if I pick the wrong side?

One undo brings everything back, because the whole operation is a single step in the command history.

Can I call it from my own LISP routine?

Not with the command function. We tried, and the program answered Unknown command "EXTRIM", because this is a LISP-defined command rather than a core one.

About the author

TS. Đỗ Quốc Hoàng — Vice Director of the Institute of Information Technology in Civil Engineering, Hanoi University of Civil Engineering, and a specialist in software development for construction