Window a rectangle and everything outside it disappears — anything that crosses the edge is trimmed off cleanly at the boundary rather than left hanging. Or do the reverse, and punch the rectangle out of the drawing.
What ClipBox does
This is what you want when lifting a detail out of a large plan, cutting a supplied drawing down to the bit you actually need, or clearing a hole for something new. By hand it means a window erase and then trimming a dozen stragglers one at a time.
CLIPKEEP keeps what is inside the rectangle. CLIPWIPE removes what is inside. CLIPBOX asks which, and whether to leave the boundary drawn.
How to use it
- Load the routine with
APPLOAD, or put it on your support file search path. - Type
CLIPBOX, or go straight toCLIPKEEPorCLIPWIPE. - Window the rectangle.
- Read the report — anything on a locked layer is named and skipped.
How it works
A closed polyline is built on the rectangle and used as the cutting edge for TRIM. Everything wholly on the unwanted side is erased outright; only what straddles the boundary needs trimming, and the boundary itself does the cutting.
The trim runs as four separate fence lines, one per side, rather than one fence round the whole rectangle. That is not tidiness: a fence that turns a corner behaves unpredictably at the corner itself, and four straight passes are reliable where one folded pass is not.
The one thing that matters on a modern AutoCAD. From AutoCAD 2021, TRIM defaults to Quick mode, which does not ask which objects to use as cutting edges — it works everything out for itself. Any older routine that feeds TRIM a cutting edge and then a fence, as this one does, has its answers read as something else entirely, and either fails or trims the wrong things.
The fix is TRIMEXTENDMODE, set to 0 for Standard behaviour while the routine runs and put back afterwards. It is read through a guard, because the variable does not exist before 2021 and asking for a system variable that is not there is itself an error.
Notes and limits
- Objects on locked layers are reported and skipped, not silently left. Erasing them would fail and stop the run.
- The boundary is built directly, not with PLINE, so a running object snap cannot pull a corner to nearby geometry and clip the wrong rectangle.
- One undo group covers everything, so putting it back is a single
U. - This deletes drawing content. Check the rectangle before confirming.
Download and details
| Name | ClipBox — clip a drawing to a rectangle, trimming cleanly at the edge |
| Download | ClipBox.lsp — 11.2 KB, plain AutoLISP source. Downloads directly; no zip to unpack. |
| Type | AutoCAD AutoLISP routine |
| Commands | CLIPBOX, CLIPKEEP, CLIPWIPE |
| Requires | nothing beyond a CAD platform with AutoLISP. |
| Source size | 11.2 KB, 265 lines |
| Error handling | Yes — a *error* handler restores every system variable it changed, on cancel as well as on error. |
| Undo | The whole operation is wrapped in a single undo group, so one U reverses all of it. |
| Compatibility | AutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer. |
| Author | YZ, August 2026 |
| Licence | Free to use, supplied “as is” with no warranty. |
References
- FENCECUT LISP — split objects along a line without deleting anything
- SHRINKWRAP LISP — outline a selection rather than clip to a box
- CORRAL LISP — select inside an irregular boundary
- More free AutoLISP routines on this site
- Wisey’s Steel Shapes — free structural steel section drawing program