Updated to AutoCAD 2000!

15. Working with Linetypes, Part 1

by Ralph Grabowski

Last lesson, we ended our three-part look at hatch patterns and how to create them. It is tricky creating a new hatch pattern. Fortunately, once you've been exposed to hatch patterns, creating a custom linetype is trivial.

Until Release 13, linetypes were strictly one-dimensional. They consisted of lines, gaps, and dots put together in a variety of patterns. Since Release 13 (and LT Release 3), Autodesk extended linetypes so that I can now include 2D shapes and text, such as railroad tracks and -- HW -- for a hot water line. The 1D linetypes are called "simple" and the 2D linetypes are called "complex." AutoCAD comes with a number of simple linetypes, stored in the Acad.Lin file found in the \support folder (Aclt.Lin in AutoCAD LT). The sample complex linetypes are stored in file Ltypeshp.Lin. The text for the complex linestyles is stored in Ltypeshp.Shx.

Commands that Affect the Linetype

Like hatch patterns, linetypes are defined in a LIN file external to AutoCAD. It's always been a source of irritation to me that I gotta load the file into the drawing before I use any linetype. The Linetype command (or its command-line cousin, -Linetype) loads the linetypes and lists the linetypes already loaded.

Like a color, I apply a linetype to an individual object with the Linetype command, or I can have all objects located on a layer with the same linetype, via the Layer command.

Like text, linetypes are tricky to size. I have to size the gaps and dashes just the right way. Too small, and the line looks solid (but takes a suspiciously long time to redraw). Too large, and the line looks solid, too. It's the LtScale command that lets me set the scale of the linetype. Typically, the scale I use for text and dimensions and hatch patterns also applies to the linetype. Nice, eh?

Until Release 13, the linetype scale factor applied equally to all linetypes in the drawing; as of Release 13 -- and LT R3 -- I can apply an individual linetype scale factor for each and every object in the drawing. (That's probably one reason R13 files are 40% larger than the same R12 file!)

And quickly now, the other commands that affect linetypes: MatchProp (aka Painter) is another way to set the linetype. The Change, ChProp, DdChProp, DdModify and Properties commands let me change the linetype and scale. Rename and DdRename change the name of linetypes. Purge removes unused linetype definitions.

System Variables that Affect Linetypes

Because linetypes are affected by scale (which reminds me: I have to do something about those scales on my Red Maple tree), paper space becomes a problem. A linetype scale that looks fine in model space is going to look wrong in paper space. The solution comes with the PsLtScale system variable. When set to 0, PsLtScale scales linetypes the same in model space and in layouts. But when set to 1, linetypes in layouts are drawn to the same scale as the viewport's scale.

Another system variable is needed for polylines. That's because linetypes are normally generated from vertex to vertex along the polyline. Stop and go, just like rush hour traffic. To overcome this, Autodesk added the PLineGen system variable. When changed to 1, the linetype is drawn from one end of the polyline to the other end, instead of from vertex to vertex.

There are a couple of other system variables that relate to linetypes. CeLtype holds the name of the linetype currently in effect. LtScale stores the current linetype scale factor (default = 1.0).

The Special Case of Polylines

Then, there's the trick when it comes to polylines. To understand the problem, I have to understand how AutoCAD generates a linetype. AutoCAD attempts to apply the linetype as nicely as it can, based on the length of the object and the linetype scale factor. Essentially, it starts at one end of the object and works its way to the other end. Then AutoCAD centers the linetype pattern so that it looks nice and even at both ends. I never get the linetype abruptly ending midway through at the end of a line.

Consider, then, the polyline. While it looks like one long connected line-arc-spline, it has many vertices, even if I cannot see them. AutoCAD used to faithfully restart the linetype pattern each time it encountered a vertex. When the vertices are close together, AutoCAD never gets around to starting the pattern, resulting in a solid or continuous line. This would drive some people nuts, like cartographers who use polylines for drawing contours. As of Release 13 (and LT R3), the problem has been fixed with the PlineGen system variable. When set to 0 (the default), AutoCAD works like before, generating the linetype from vertex to vertex. When changed to 1, AutoCAD generates the linetype from one end of the polyline to the other end -- ah, instant relief!

Customizing Linetypes

Like hatch patterns, AutoCAD has two ways of creating a different linetype: (1) at the command prompt; and (2) with a text editor. Let's look at the first one first. Follow these steps to create a new linetype on-the-fly:

1. Start AutoCAD and type the -Linetype Create command:

2. Give a name to the linetype. This takes three steps. The first step is the name itself, which can be as long as 31 characters. Let's name our pattern "Dit-dah" (which Morse code types recognize as the letter A -- and is the only Morse code I know):

3. Unlike creating a custom hatch pattern on-the-fly, AutoCAD actually stores my new linetype in a LIN file, letting me reuse it later. At this point, AutoCAD pops up the Create or Append Linetype dialog box. That lets me place my custom linetype in a new LIN file or else have AutoCAD append the linetype description to the Acad.Lin. I find it easiest to keep all linetypes in one file, so I recommend accepting Acad.Lin -- or AcadIso.Lin if I tend to work with the ISO standard linetypes.

4. After I click the Save button on the dialog box, AutoCAD checks:

If two linetypes have the same name, AutoCAD would only ever read the first one it comes across. If I had (accidently or otherwise) type a linetype name that already exists -- such as Dashed -- AutoCAD would have warned me:

Press Enter and try naming it again.

5. Next I describe the linetype with any words I want up to 47 characters long.

A good descriptive text would be the pattern I plan to create, using dots, underlines, and spaces.

6. Finally! I get to define the linetype pattern. Like hatch patterns, there is a code:

I can't use the same code twice in a row. It just doesn't make sense to have two gaps or two lines in a row, does it? Instead, code that gap or line twice as long. There are two more codes I need to know about:

I type the codes after the A, as follows:

I could go on for a total of 78 characters but I won't.

6. I press [Enter] to end linetype definition and I'm done. Well, not quite. I still need to test the pattern. Which is exactly what we'll do next month.

Where Did 47 Come From?

Before we end this month, a question: What about those unusual character limits of 31 and 47 and 78? They come from the limit of 80 characters being the maximum length of a line in the linetype definition. So, where did 80 come from?

When you use DOS, then you know the screen has a width of 80 characters. When AutoCAD displays the contents of the Acad.Lin file on the text screen, none of the text wraps around, making a nice display. Why is the DOS screen 80 characters wide?

If you punch-coded computer cards back in the 60s and 70s, then you know that the punch cards were 80 characters wide. Why is that?

When IBM invented the punch cards, it made them the same size as the American dollar bill of the time (which were smaller than the current dollar bill). Why the dollar bill? I don't know for sure, but I am guessing that IBM simply adapted the bill-counting machine to make punchcard readers. Back to where 47 comes from ...

Until AutoCAD 2000, the limit to names of named objects was 31 characters (like layer names, view names, linetype names, etc). The asterisk and comma take up two characters. That leaves 47: 80 - 31 - 2 = 47.


Tailoring AutoCAD Part 14 | Part 15 | Part 16 is the next tutorial.

Comments on this tutorial series? Tell me about it.

Return to Contents.

All contents copyright 1995-9 XYZ Publishing, Ltd. . All rights are reserved. No material may be reproduced electronically or in print without written permission from XYZ Publishing, PO Box 3053, Sumas WA, 98295-3053, unless otherwise noted.