• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

CLIPBOX LISP: Clip a Drawing to a Rectangle in AutoCAD

August 6, 2026

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

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type CLIPBOX, or go straight to CLIPKEEP or CLIPWIPE.
  3. Window the rectangle.
  4. 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

NameClipBox — clip a drawing to a rectangle, trimming cleanly at the edge
DownloadClipBox.lsp — 11.2 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandsCLIPBOX, CLIPKEEP, CLIPWIPE
Requiresnothing beyond a CAD platform with AutoLISP.
Source size11.2 KB, 265 lines
Error handlingYes — a *error* handler restores every system variable it changed, on cancel as well as on error.
UndoThe whole operation is wrapped in a single undo group, so one U reverses all of it.
CompatibilityAutoCAD (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.
AuthorYZ, August 2026
LicenceFree 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

Filed Under: AutoLISP Routines

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in