AutoCAD • Drawing and Editing Fundamentals

Trim, Extend & Lengthen — Trim, extend, and lengthen objects

Master the essential editing commands that precisely modify object boundaries and lengths in AutoCAD drawings.

A drafting compass with dimension and drawing-panel symbols.
Inside this lesson 10 sections 5 questions 8 figures

SECTION 1

Historical Context & Motivation

Computer-aided design fundamentally transformed the way engineers and architects modify geometry, replacing the tedious manual process of erasing and redrawing lines on drafting vellum with precise, algorithmic editing commands. In traditional drafting, trimming a line to a boundary meant physically scraping ink or using an eraser shield—operations that were imprecise and irreversible. The development of Trim, Extend, and Lengthen commands in CAD software emerged from the need to computationally solve the intersection and projection problems that drafters had always performed by hand. These commands encode geometric algorithms—ray-boundary intersection tests, parametric curve extension, and delta-length modifications—into single-keystroke operations, dramatically accelerating the editing workflow.

1963 • Sketchpad by Ivan Sutherland

The first interactive computer graphics system demonstrated constraint-based geometry editing, laying the conceptual groundwork for boundary-aware modification of graphical objects.

1982 • AutoCAD Release 1

Autodesk released the first commercial version of AutoCAD for personal computers, introducing fundamental editing commands including early trim and extend functionality that operated on 2D line segments.

1997 • AutoCAD Release 14 — Enhanced Edge Modes

AutoCAD introduced edge extension modes for Trim and Extend, allowing cutting edges and boundary edges to be projected beyond their physical endpoints for more flexible editing.

2011 • AutoCAD 2012 — Fence & Crossing Selection

Advanced selection methods such as fence and crossing were fully integrated into Trim and Extend, enabling batch operations on multiple objects in a single command invocation.

2020 • AutoCAD 2021 — Quick Trim Mode

The Trim command received a major workflow update: by default, all geometry acts as a cutting edge, eliminating the need to select boundaries first. This shift reflected modern UX design principles favoring speed and reduced cognitive load.

The underlying question these commands address is deceptively simple: given a geometric object and a boundary constraint, how do we algorithmically determine which portion of the object to retain, remove, or extend? For computer science students, understanding these operations connects directly to computational geometry concepts such as line-line intersection, parametric curve evaluation, and spatial indexing for efficient boundary detection.

SECTION 2

Core Principles & Definitions

Before diving into command-specific details, it is essential to understand the foundational concepts that unify Trim, Extend, and Lengthen. All three commands modify the parametric extent of an object—that is, they change where along its defining curve the visible portion begins or ends. AutoCAD stores geometric objects internally as parametric entities: a line segment is defined by two endpoint parameters, an arc by a center, radius, and start/end angles, and a polyline by a sequence of vertex parameters. Trim, Extend, and Lengthen each manipulate these parameters differently, but they share the common abstraction of adjusting an object's effective domain along its parent curve.

1

Cutting / Boundary Edge

A reference object that defines where trimming or extending stops. In Trim, this is the cutting edge; in Extend, it is the boundary edge. Computationally, AutoCAD solves the intersection of the target object's extension with this edge.
2

Object Selection Side

For Trim, the side of the cutting edge on which you click determines which portion is removed. This is analogous to a Boolean subtraction where your click position serves as the region selector.
3

Edge Extension Mode

The EDGEMODE system variable (0 or 1) controls whether cutting/boundary edges are considered at their physical extent or their infinite mathematical extension. Mode 1 projects the edge to its theoretical infinite length.
4

Delta vs. Absolute Length

The Lengthen command offers multiple sub-options: DELta adds or subtracts a fixed amount, Percent scales proportionally, Total sets an absolute value, and DYnamic uses real-time cursor input.
✦

KEY TAKEAWAY

Think of these three commands as string operations on a parametric curve. Trim is like substring(0, intersectionIndex)—it truncates to a boundary. Extend is like appending characters until a delimiter is reached. Lengthen is like resize(newLength)—a direct, numeric length modification without any boundary reference.

SECTION 3

Visual Explanation — Trim & Extend Workflow

The following diagram illustrates the core behavior of the Trim and Extend commands side by side, showing how an initial geometry configuration is modified by each operation. On the left, a horizontal line crosses a vertical cutting edge, and the portion beyond the edge is removed by Trim. On the right, a horizontal line that falls short of a vertical boundary edge is extended to meet it. Understanding these two complementary operations visually clarifies why AutoCAD allows you to switch between them with a simple Shift key modifier during command execution.

TRIM CommandEXTEND CommandBeforeCutting EdgeClick here →After TRIMRemovedRetainedBeforeBoundary Edge← Click near endAfter EXTENDExtended
Left: The TRIM command removes the portion of the blue line beyond the pink cutting edge, based on where you click. Right: The EXTEND command lengthens the blue line until it meets the amber boundary edge. During either command, holding Shift temporarily switches to the other.

A critical detail visible in the diagram is the role of click position. In Trim, AutoCAD uses the click location to determine which segment of the split object to discard—the segment on the side of the click relative to the cutting edge. In Extend, the click must be near the endpoint that should grow toward the boundary edge. This click-position sensitivity means the same geometric configuration can yield different results depending on where the user selects, a design decision that reflects the principle of minimal ambiguity in interactive geometry editing.

SECTION 4

How It Works — Underlying Geometry

Although AutoCAD abstracts the underlying mathematics into a single mouse click, the Trim, Extend, and Lengthen commands internally rely on classical computational geometry algorithms. Understanding these gives computer science students insight into how CAD kernels process editing operations efficiently, especially when dealing with complex drawings containing thousands of entities.

Intersection Computation for Trim & Extend

LINE-LINE INTERSECTION (PARAMETRIC FORM)

P=P1+t(P2−P1),Q=P3+u(P4−P3),t=((P3−P1)×(P4−P3))/((P2−P1)×(P4−P3))P = P₁ + t(P₂ − P₁), Q = P₃ + u(P₄ − P₃), t = ((P₃ − P₁) × (P₄ − P₃)) / ((P₂ − P₁) × (P₄ − P₃))

P₁P₂ is the target object, P₃P₄ is the cutting/boundary edge. The parameter t gives the intersection point along the target line. For Trim: the object is split at t, and the unwanted segment is deleted. For Extend: t may lie outside [0, 1], indicating the target must grow to reach the edge. The × operator denotes the 2D cross product (x₁y₂ − x₂y₁).

LENGTHEN — DELTA MODE

Lnew=Lold+ΔLL_new = L_old + ΔL

Where L_old is the current arc length or line length, and ΔL is a signed increment. A positive ΔL extends the object; a negative ΔL shortens it. The endpoint nearest to the click is the one that moves.

LENGTHEN — PERCENT MODE

Lnew=Lold×(P/100)L_new = L_old × (P / 100)

Where P is the percentage value entered by the user. A value of 150 extends the object to 150% of its original length; a value of 75 shortens it to 75%. For arcs, this modifies the included angle proportionally.

ℹ

EDGEMODE System Variable

When EDGEMODE = 0, AutoCAD only considers the physical extent of cutting/boundary edges—the parameter t must satisfy 0 ≤ u ≤ 1 for the edge as well. When EDGEMODE = 1, the edge is treated as its infinite extension (no constraint on u), enabling trimming or extending to implied intersections. This is equivalent to extending the edge's parametric domain to (−∞, +∞).

SECTION 5

Detailed Breakdown of Each Command

Each of the three commands has distinct invocation syntax, sub-options, and behavioral nuances. The following diagram presents the command flow for all three operations as a decision tree, illustrating how user inputs route through different execution paths. This structured view mirrors how the AutoCAD command interpreter parses input—a state machine that transitions based on keyword or pick-point input.

Command Flow: TRIM / EXTEND / LENGTHENTRIM (TR)Select cutting edges (or ↵)Press Enter to confirmClick objects to trimOptions:Fence | Crossing | Edge | eRaseHold Shift →switches to EXTENDEnter / Esc to exitEXTEND (EX)Select boundary edges (or ↵)Press Enter to confirmClick objects to extendOptions:Fence | Crossing | EdgeHold Shift →switches to TRIMEnter / Esc to exitLENGTHEN (LEN)No boundary selection neededSub-options:DELta | PercentTotal | DYnamicEnter value / angleClick object near endpointObject modifies fromthe clicked endpointEnter / Esc to exit
Three parallel command flows: TRIM (left) and EXTEND (center) share a symmetric structure—select edges, then select objects—and can switch via Shift. LENGTHEN (right) requires no boundary edge and instead uses numeric or dynamic input to modify object length directly.
FeatureTRIMEXTENDLENGTHEN
AliasTREXLEN
Requires boundary?Yes (cutting edge)Yes (boundary edge)No
Works on closed objects?Yes (splits at intersection)No (open objects only)No (open objects only)
Supported object typesLines, arcs, circles, polylines, splines, ellipses, rays, xlinesLines, arcs, polylines, splines, ellipsesLines, arcs, polylines, splines
Shift toggleShift → ExtendShift → TrimN/A

Feature comparison across all three editing commands

SECTION 6

Worked Example — Editing a Floor Plan Opening

Consider a practical scenario: you are drafting a floor plan and need to create a 3-foot door opening in a wall line, extend a partition wall to meet the exterior wall, and adjust a countertop line to a specific length. This example exercises all three commands sequentially, as would occur in a real editing workflow.

Creating a Door Opening and Adjusting Partitions

  1. 1

    Step 1 — Draw the initial geometry

    Begin with a horizontal wall line from (0, 0) to (20, 0) representing the exterior wall. Draw two short vertical construction lines at x = 5 and x = 8 to mark the 3-foot door opening boundaries. Draw a vertical partition line from (12, −6) to (12, −1), which stops 1 unit short of the exterior wall.
  2. 2

    Step 2 — TRIM the wall for the door opening

    Invoke the TRIM command by typing TR and pressing Enter. Select the two vertical construction lines at x = 5 and x = 8 as cutting edges, then press Enter. Now click on the horizontal wall line between x = 5 and x = 8. AutoCAD computes the intersections at (5, 0) and (8, 0), determines that the clicked segment lies between these two intersections, and removes that segment.
    The wall line is split into two segments: (0, 0)→(5, 0) and (8, 0)→(20, 0), creating a 3-unit opening.
  3. 3

    Step 3 — EXTEND the partition to meet the exterior wall

    Type EX and press Enter. Select the remaining segment of the exterior wall (8, 0)→(20, 0) as the boundary edge, then press Enter. Click the partition line near its upper endpoint at (12, −1). AutoCAD projects the partition line along its direction (vertical, upward) and finds the intersection with the boundary edge at (12, 0).
    The partition line now runs from (12, −6) to (12, 0), meeting the exterior wall precisely.
  4. 4

    Step 4 — LENGTHEN the countertop line

    Suppose a countertop line runs from (14, −3) to (18, −3) with a length of 4 units, but the design requires a total length of 6 units. Type LEN and press Enter. Select the Total sub-option by typing T. Enter 6 as the new total length. Click the line near its right endpoint at (18, −3).
    The line extends from its right endpoint to (20, −3), achieving the required 6-unit total length. The left endpoint at (14, −3) remains fixed because the right endpoint was closer to the click.
  5. 5

    Step 5 — Clean up construction lines

    The two vertical construction lines at x = 5 and x = 8 are no longer needed. You can use the ERASE command or, conveniently, the eRase sub-option within the TRIM command. This is a workflow optimization: while trimming, typing R switches to erase mode, allowing you to remove helper geometry without exiting the active command.
    Final geometry: a wall with a 3-foot opening, a partition meeting the wall, and a 6-unit countertop—all edited without redrawing any objects.

SECTION 7

Strengths, Limitations & When to Use Each

Choosing between Trim, Extend, and Lengthen—or using them in combination—depends on the editing context. Each command has distinct advantages and constraints that make it optimal for certain scenarios. The table below provides a systematic comparison that can guide your decision-making process, much like selecting the right data structure in a programming task based on operational complexity requirements.

CriterionTRIMEXTENDLENGTHEN
StrengthPrecise boundary-based removal; batch processing via fence selectionGuarantees exact intersection with boundary; mathematically clean joinsNumeric precision without needing reference geometry; supports percentage and dynamic modes
LimitationRequires at least one cutting edge; cannot operate on objects with no nearby intersectorsOnly works on open objects; the boundary must be reachable along the object's natural trajectoryCannot ensure intersection with other objects; the result may leave gaps or overlaps
Best use caseRemoving overhanging segments at intersections; creating openings in walls or boundariesClosing gaps between lines that should meet; completing boundaries to a referenceAdjusting lengths to precise numeric values; proportional resizing of elements
Computational modelIntersection detection → split → delete selected segmentParametric projection → intersection detection → endpoint modificationArc-length computation → delta/percent/total recalculation → endpoint repositioning

Decision matrix for selecting the appropriate editing command

🔧

DECISION HEURISTIC

Apply this simple heuristic: if you need to remove geometry relative to a boundary, use TRIM. If you need to grow geometry to reach a boundary, use EXTEND. If you need to resize geometry by a known amount with no boundary involved, use LENGTHEN. Think of it like version control: TRIM is deleting lines from a file up to a marker, EXTEND is appending lines until a pattern is reached, and LENGTHEN is simply setting the file to a target line count.

SECTION 8

Connection to Advanced Editing & Automation

The Trim, Extend, and Lengthen commands serve as the foundational layer upon which more sophisticated AutoCAD editing techniques are built. Understanding their underlying logic is essential for leveraging advanced features such as AutoLISP scripting, dynamic blocks, and parametric constraints. For computer science students, the connection to programmatic geometry manipulation is particularly relevant—AutoCAD's .NET API and AutoLISP both expose trim and extend operations as callable functions, enabling automated drawing cleanup and intelligent geometry processing in batch workflows.

Basic CommandAdvanced Counterpart
TRIM / EXTEND (interactive)AutoLISP (command "TRIM" ...) — scriptable trim in batch routines; .NET Editor.Command() for programmatic control
LENGTHEN with delta/percentParametric constraints (DELCONSTRAINT, dimensional constraints) — objects auto-resize when parameters change
Manual boundary selectionBOUNDARY command + region Boolean operations — automated boundary detection using flood-fill algorithms
Edge mode extensionXLINE / RAY construction geometry — infinite lines used as persistent reference boundaries in complex layouts

Mapping basic editing commands to their advanced equivalents

💡

AutoLISP Example

A simple AutoLISP expression to trim all objects crossing a selected boundary: (command "TRIM" boundary_entity "" target_entity ""). This programmatic invocation mirrors the interactive flow—first the cutting edge, then the target—but can be embedded in loops to process hundreds of objects. For CS students comfortable with scripting, this is the bridge between interactive CAD and procedural geometry processing.

Looking ahead, modern CAD systems are increasingly incorporating machine-learning-assisted editing, where the system infers user intent from context—for example, automatically identifying which segments to trim when a wall intersection is modified. The algorithmic foundation, however, remains the same parametric intersection logic that Trim and Extend have used since the 1980s. Mastering these commands at the conceptual level equips you to both use the tools effectively today and contribute to the next generation of intelligent design software.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

Explain why AutoCAD's TRIM and EXTEND commands share a Shift-key toggle. From a software design perspective, what principle does this reflect, and how does the shared workflow benefit users editing complex drawings?
Show answer
TRIM and EXTEND are mathematical inverses—both operate on the same intersection point but differ only in which portion of the object is retained versus removed. The Shift toggle reflects the software design principle of modal symmetry: since both commands require the same initial setup (selecting boundary/cutting edges), allowing instant switching eliminates redundant steps. This benefits users editing complex drawings because it acknowledges that during a single editing session, you frequently alternate between shortening objects that overshoot boundaries and lengthening objects that fall short. Without the toggle, users would need to exit one command, invoke the other, re-select edges, and then select targets—a fourfold increase in interaction cost.

Question 2: BASIC CALCULATION

A line segment runs from (2, 3) to (10, 3). A vertical cutting edge exists at x = 6. If you invoke TRIM and click on the line at approximately (8, 3), what are the endpoints of the remaining line segment?
Show answer
The horizontal line intersects the vertical cutting edge at (6, 3). When you click at (8, 3), you are selecting the segment on the right side of the cutting edge, which spans from (6, 3) to (10, 3). TRIM removes the clicked segment, so the remaining line runs from (2, 3) to (6, 3). The intersection point (6, 3) becomes the new endpoint of the trimmed line. If you had clicked at (4, 3) instead, the left segment would have been removed, leaving (6, 3) to (10, 3).

Question 3: INTERMEDIATE

You have a line from (0, 0) to (4, 3) and a boundary edge along the line y = 5. With EDGEMODE set to 1, can EXTEND reach this boundary? Calculate the intersection point and the extended line's new endpoint.
Show answer
The line from (0, 0) to (4, 3) has a direction vector of (4, 3), giving it a slope of 3/4. The parametric form is P(t) = (0 + 4t, 0 + 3t) for t ∈ [0, 1]. To find the intersection with y = 5, solve 3t = 5, yielding t = 5/3 ≈ 1.667. Since t > 1, the intersection lies beyond the physical extent of the line. With EDGEMODE = 1, AutoCAD projects both the target line and the boundary edge (in this case, y = 5 is inherently infinite), so the extension is valid. Substituting t = 5/3 into the x-component: x = 4 × (5/3) = 20/3 ≈ 6.667. The extended line's new endpoint is (20/3, 5), approximately (6.667, 5). With EDGEMODE = 0, this operation would fail because the intersection parameter exceeds the physical domain.

Question 4: APPLIED

You are scripting an AutoLISP routine to clean up a floor plan. The plan has 50 interior wall lines that overshoot the exterior boundary rectangle. Describe the algorithmic approach you would use to trim all overshooting segments programmatically, and identify the TRIM sub-option that would make this most efficient interactively.
Show answer
Programmatically, you would first select the four lines of the exterior boundary rectangle as cutting edges using a selection set filter (e.g., SSGET with entity type filter for LINE on the boundary layer). Then, for each of the 50 interior wall lines, you would invoke TRIM with the boundary as the cutting edge and the wall line as the target, using a pick point computed to lie outside the boundary rectangle. In AutoLISP, this translates to a loop: (foreach wall wall-list (command "TRIM" boundary-ss "" wall "")). Interactively, the most efficient approach is the Fence selection mode: after selecting all four boundary edges and pressing Enter, type F for Fence, then draw a polyline path outside the rectangle that crosses all 50 overshooting segments. This performs all 50 trims in a single selection operation, reducing the interaction from O(n) clicks to O(1) fence path.

Question 5: CRITICAL THINKING

Consider the computational complexity of the TRIM command when applied to a drawing with n objects and k cutting edges. What is the time complexity of identifying all valid trim points, and how might spatial indexing (e.g., R-trees or quadtrees) improve performance? Discuss whether AutoCAD's 2021 'Quick Trim' mode (all objects as cutting edges) changes this analysis.
Show answer
In the naive case, trimming a single object against k cutting edges requires O(k) intersection tests, each of which is O(1) for line-line intersections or O(m) for spline-spline intersections where m is the spline degree. If we trim n objects, the total complexity is O(n × k). In the 2021 Quick Trim mode, k = n − 1 (every other object is a potential cutting edge), making the complexity O(n²)—a significant concern for large drawings. Spatial indexing with R-trees or quadtrees reduces this by restricting intersection tests to objects whose bounding boxes overlap. An R-tree query for objects near a given target takes O(log n + r), where r is the number of nearby results, reducing the total to approximately O(n(log n + r̄)) where r̄ is the average number of nearby objects. For sparse drawings with bounded local density, r̄ is effectively constant, yielding O(n log n). AutoCAD likely implements such spatial indexing internally, which is why Quick Trim performs acceptably even on complex drawings—the quadratic worst case is mitigated by spatial locality in typical CAD geometry.

SUMMARY

Lesson Summary

Summary

This lesson covered three essential AutoCAD editing commands that modify the parametric extent of geometric objects. TRIM removes portions of objects that cross a cutting edge, using intersection detection to determine where to split and which segment to delete based on click position. EXTEND grows an object along its natural trajectory until it intersects a boundary edge, solving a parametric projection problem. LENGTHEN provides boundary-independent resizing through four sub-options: DELta, Percent, Total, and DYnamic. The EDGEMODE system variable controls whether edges are treated at their physical extent or as infinite projections.

From a computational perspective, all three commands reduce to fundamental operations in computational geometry: line-line and curve-curve intersection for Trim and Extend, and arc-length recalculation for Lengthen. The Shift-key toggle between Trim and Extend reflects their mathematical duality—both share the same intersection computation but differ in which side of the intersection point is preserved. These commands form the editing backbone that scales from simple manual workflows to AutoLISP and .NET automation, making them indispensable for any CAD practitioner or developer building tools on top of AutoCAD's geometry engine.

Varsity Tutors • AutoCAD • Trim, Extend & Lengthen — Trim, extend, and lengthen objects