BIM

The line command in AutoCAD: three commands, three kinds of end

The line command in AutoCAD is really three commands. LINE gives a segment with two ends, RAY a half-infinite ray, XLINE an infinite construction line.

  • TS. Đỗ Quốc Hoàng
  • 9 min read
Four infinite construction lines setting out a room, with the walls drawn over them using LINE Photo: Screenshot taken on AutoCAD 2027 at the Institute

Ask which command draws a straight line and almost everyone says LINE. That answer is one third right. The line command in AutoCAD is really three commands, and they differ in exactly one thing: how many ends the line has.

This article measures all three on AutoCAD 2027 at the Institute, including figures the documentation does not give. For the whole 2D drafting workflow, see the AutoCAD for Construction course.

Three commands, and what tells them apart

Give all three the same start point and the same direction and you get three different things.

Three line commands Photo: The same start point and direction. LINE stops at the second point, RAY leaves the view on one side, XLINE leaves it on both

LINE gives a segment with two ends: real drawing geometry. RAY gives a ray, with a start point and an end that runs to infinity. XLINE has no ends at all and runs to infinity both ways.

So the line command in AutoCAD is a family, not a single tool. The last two members are not drawing geometry. They are setting-out lines, to be deleted or switched off once the shape is built.

CommandWhat it createsAlias measured on the machine
LINEa segment with two endsL
RAYa ray, infinite one wayno alias at all
XLINEinfinite both waysXL

That "no alias" entry is read straight out of acad.pgp on the machine, not guessed. In the same file LINE has L, XLINE has XL and PLINE has PL. To call RAY you type all three letters.

LINE: every segment is its own object

This is where beginners trip. Type L, click four points, and the screen shows one continuous chain. AutoCAD does not see it that way.

We drew three segments with LINE and counted the objects created, then drew the same three with PLINE as a control:

Three connected segments drawn withObjects created
LINE3
PLINE1

The consequence is practical. To select a chain drawn with LINE you have to window all three; a single click picks one segment. To turn them into one object, use JOIN or PEDIT.

The prompts, copied from the 2027 command line:

Specify first point:

Specify next point or [Undo]:

Specify next point or [Close/Undo]:

Note that Close appears only from the second segment onward — before that there is nothing to close. Autodesk's LINE page describes the two options in one sentence each: "Close: Connects the first and last segments" and "Undo: Removes the most recent segment of a line sequence".

Typing U mid-command removes the last segment without ending the command. Draw one segment wrong and use this; do not quit and start again.

One more behaviour is not in the option list at all: press Enter at Specify first point: and the command takes the end of the last line segment you drew as its start point, then asks for the next point. To carry on from where you stopped, that is the fastest route.

Four ways to answer a point prompt

Every drawing command asks for points, and there are four ways to answer. Good drafters use all four.

MethodWhat you typeWhen
Absolute coordinates0,0the first point of a drawing
Relative coordinates@3600,0walls; the most used by far
Relative polar@3600<90when you know length and angle
Direct distance entrymove the mouse, type 3600fastest; needs F8 on

The fourth is what professionals use nearly all day. Turn on ortho with F8 so the cursor only travels horizontally or vertically, point it the way you want, and type the length.

One small trap costs a lot of people a lot of time: the comma in a coordinate separates two numbers; it is not a decimal mark. A machine set to a locale that uses the comma as decimal separator is the source of points that jump somewhere unexpected. In AutoCAD, decimals are written with a full stop. Coordinate entry in full is covered in our article on entering coordinates.

XLINE: the infinite construction line

Plenty of people look for the setting-out command without knowing its name. It is XLINE, alias XL. Autodesk describes it in one sentence: "Creates a construction line of infinite length."

Call it and the prompt reads, verbatim:

Specify a point or [Hor/Ver/Ang/Bisect/Offset]:

Five words in brackets, five ways to build the line, plus the default makes six.

OptionWhat it does
(default)pick a point, then a second; it keeps asking until you press Enter
Horhorizontal, asks only for a point to pass through
Ververtical, asks the same way
Angangled; asks for the angle first, then the point
Bisectbisector; asks for the vertex, then a point on each side
Offsetparallel to an existing object at a stated distance

Hor and Ver are the quickest way to set out a grid. The image at the top of this article is exactly that: two Hor and two Ver on layer AXIS, with the walls drawn over them using LINE. The four setting-out lines run off the edge of the view in every direction, which is the whole point of an infinite line.

The Offset option sounds like the OFFSET command but differs in one way: it produces an infinite line rather than a segment with two ends. The real OFFSET is covered in our article on drawing parallel lines.

The ray command, and where it beats XLINE

RAY gets little use, but there is one job it does better. Autodesk: "Creates a linear object that starts at a point and continues to infinity."

The prompts are just two, with no options:

Specify start point:

Specify through point:

Where it wins is as a trim boundary. Run a check line up from the nose of a stair tread and a ray only travels upward. An xline would also reach down below the slab, hiding the foundation linework for no benefit at all.

Does an infinite line blow up the drawing extents?

This is the question everyone worries about and no document answers with a number: does a line of infinite length send ZOOM Extents off to infinity?

We measured it. Read EXTMIN, add an XLINE well below every existing object, run REGENALL, read it again:

MeasurementEXTMIN in Y
Before adding the XLINE−527762.9
After adding it below everything else−527762.9
Control: a plain LINE at the same level−529262.9

That last row is the negative control, and it matters as much as the two above it. It proves the measurement is capable of detecting a change: an ordinary line at the same place moves EXTMIN at once. Only the infinite ones do not.

We repeated it with RAY and got the same result: EXTMIN does not budge.

So XLINE and RAY sit outside the drawing extents. Scatter as many as you like and ZOOM Extents stays sane. The thing to watch is different: they still plot if their layer is on, so give them their own layer and switch it off before printing.

What trimming an infinite line leaves behind

The documentation says to cut setting-out lines back with TRIM. No document says what you are left with. We measured.

We ran an XLINE horizontally across two vertical segments, then trimmed the piece in the middle, reading the object type before and after:

ActionWhat remains
Before trimming1 XLINE
Trim out the middle piece2 RAY objects
Trim off one end1 RAY

In hindsight it is obvious, which makes it odd that nobody writes it down. Cut one end off a doubly infinite line and what is left is, by definition, a ray. Cut the middle out and you have two rays back to back.

This matters when cleaning up a drawing. You filter by object type XLINE, delete them all, and believe the job is done — but every line that was ever trimmed is now a RAY and stays behind. A QSELECT sweep has to cover both types.

Three things often repeated that are not true

Often repeatedWhat we measured on the 2027 release
A straight line means the LINE commandThree commands, differing in how many ends the line has
Drawing a chain with LINE gives one objectThree segments give three objects; use PLINE for one
Infinite lines break ZOOM ExtentsEXTMIN does not change; the control with LINE changes it at once

Frequently asked questions

Which command should I use to draw a straight line?

It depends what the line is for. Real geometry takes LINE, or PLINE if you want the whole chain as a single object. Setting-out work takes XLINE or RAY.

Why does typing RA or R not start RAY?

Because RAY has no alias. We read acad.pgp on the machine and no entry points to it. Type all three letters and press Enter.

How do I clear every construction line out of an unfamiliar drawing?

Use QSELECT, pick object type Construction Line and delete. Then repeat it for Ray, because any construction line that was trimmed now carries the RAY type rather than XLINE.

I drew four segments and pressing C did not close them.

Close only appears from the second segment onward, and only while LINE is still running. Once the command has ended, C means nothing to the geometry you just drew.

Do construction lines print?

Yes, if their layer is on and set to plot. The tidiest habit is to give them a layer of their own and switch it off before printing, the same discipline as managing linework in our article on the zoom command.

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