AutoCAD – Drawings

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. Object count and total length before and after, on both sides.

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

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. 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."

The program reports its definition file as 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", exactly that line. The command function reaches core commands only, and this one is defined by LISP.

Where to start the EXTRIM command in AutoCAD

We searched both the 2027 interface configuration file and the Express Tools one. The answer is short.

RouteDetail
Full commandEXTRIM
Aliasnone
Ribbonno button
Classic menuno entry
Toolbarno button

Five rows and four "none". This command can only be started by typing its name. The Express Tools configuration declares 66 commands with buttons and menu entries, and this is not one of them.

That also settles a line found in several tutorials: "pick EXTRIM from the toolbar". No toolbar carries it.

Since it takes six letters every time, this is a good candidate for an alias of your own, which is covered in our article on command aliases.

The prompts, step by step

The whole command is two questions. The middle column is copied verbatim from the 2027 release, ellipsis included.

StepWhat the program asksWhat you do
1Pick a POLYLINE, LINE, CIRCLE, ARC, ELLIPSE, IMAGE or TEXT for cutting edge...Click one object to act as the boundary
2Specify the side to trim on:Click any point on the side to discard

That is all. There is no step for selecting the objects to be cut, which is exactly where the speed comes from.

Two things to watch at step 1. You can point at one object only, not a window of several. And you must hit its linework, so pick a spot where only the boundary passes; click where two lines overlap and the program takes the other one.

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.

Try it: trimming inside and outside the same rectangle

This section is for following along in AutoCAD. Do it once and the direction stops being confusing, because you watch two identical cases come out opposite.

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 Photo: AutoCAD 2027

Step 1: build the test

Type the coordinates below rather than picking with the mouse, so your final figures match the ones here.

What to drawTypeCoordinates
Rectangle 3000 × 2000 as the cutting edgeREC0,0 then 3000,2000
First crossing line, 5000 longL-1000,500 then 4000,500 then Enter
Second crossing lineL-1000,1000 then 4000,1000 then Enter
Third crossing lineL-1000,1500 then 4000,1500 then Enter
A line 1800 long wholly insideL600,1750 then 2400,1750 then Enter
A line 5000 long wholly outsideL-1000,3000 then 4000,3000 then Enter

That is five lines, 21800 long together. The rectangle is not counted, because it is the cutting edge rather than something being cut.

Now duplicate it to get two identical cases. Type CO, select everything, Enter, base point 0,0, second point 8000,0.

Step 2: the left case, picking inside

StepThe promptWhat you do
1Command:Type EXTRIM and press Enter
2Pick a POLYLINE, LINE, CIRCLE, ARC, ELLIPSE, IMAGE or TEXT for cutting edge...Type 1500,2000 and press Enter
3Specify the side to trim on:Type 1500,1000 and press Enter

The point 1500,2000 sits on the top edge of the rectangle, and that choice matters. All three crossing lines pass through the left and right edges, so picking there risks grabbing a crossing line as the boundary instead. Nothing else passes through the top edge.

The point 1500,1000 is the centre of the rectangle, which is the inside.

Step 3: the right case, picking outside

Identical apart from the last point.

StepThe promptWhat you do
1Command:Type EXTRIM and press Enter
2Pick a POLYLINE, LINE, CIRCLE, ARC, ELLIPSE, IMAGE or TEXT for cutting edge...Type 9500,2000 and press Enter
3Specify the side to trim on:Type 9500,-500 and press Enter

The point 9500,-500 lies below the rectangle, which is the outside.

Step 4: count and compare

Select each case, leave the rectangle out, and read the Length field in Properties.

BeforePicked insidePicked outside
Number of lines585
Total length218001280015800

Both columns can be checked by hand, which is how you know the figures are 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 is present, and asking the program for the path of the command's definition file confirms it.

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 the quickest check there is.

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 the 2027 release actually does
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. The result: 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. The program answers 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