Updated to AutoCAD 2000!

16. Working with Linetypes, Part 2

by Ralph Grabowski

Last lesson, we began looking at how linetype patterns are constructed in AutoCAD. We saw that there are many commands and system variables that let you load and modify linetypes. We learned how to write a new linetype definition within AutoCAD using the -Linetype Create command, as follows:

Command: -linetype  
?/Create/Load/Set: C  
Name of linetype to create: dit-dah  
Wait, checking if linetype already defined ....  
Descriptive text: . __ . __ . __ . __  
Enter pattern (on next line):  
A, .25,-.1,0,-.1  
Command:

Unlike hatch patterns, AutoCAD stores your new linetype in the Acad.Lin file, ready for future use. (By the way, new linetypes are added to the end of the Acad.Lin file.) This lesson, we test the new linetype, learn to edit the LIN file directly, and go on to find out about complex (2D) linetypes.

Testing the New Linetype

As we learned back in the AutoLISP tutorials, it is important to test a new programming creation. As simple as they are, linetypes are no exception. I test the Dit-Dah pattern, as follows:

1. Use the -Linetype Load command to load the pattern into drawing:

2. Up pops the Select Linetype File dialog box. Select Acad.Lin and click Open. AutoCAD confirms:

3. Use the -Linetype Set command to set the linetype, as follows:

4. Here I can type either the name of a loaded linetype (such as "dit-dah") or type "?" to see which linetypes are already loaded. For fun, I'll type ? and AutoCAD tells me what I can type:

5. This time, I get serious and set the current linetype to "dit-dah":

6. Now I draw a line and appreciate the linetype it is drawn with. My debugging session is over.

Creating a Linetype with a Text Editor

Just as with the hatch pattern's Acad.Pat file, I can directly edit the Acad.Lin linetype file to create a custom linetype. Here's how:

1. Start a text editor (not a word processor), such as NotePad.

2. Load the Acad.Lin file from the \Support subdirectory.

3. When I scroll down to the end of the file, I see the Dit-Dah pattern we defined last lesson.

4. I can modify an existing linetype or add a new linetype. The process is exactly the same as when I did it within AutoCAD, with two exceptions: (1) AutoCAD isn't there to prompt me; and (2) I don't need to use the "A" prefix.

To recap, the linetype definition consists of two lines of text:

Line 1 is the header, such as "*DIT-DAH, . __ . __ . __" , where:

Line 2 is the data, such as "A, .25,-.1,0,-.1", where:

I can use ; (semi-colon) to prefix any line as a comment line. Anything after the semi-colon is ignored by AutoCAD.

5. Save the LIN file with the same name (Acad.Lin) or a new name, then test it within AutoCAD.

Complex (2D) Linetypes

Introduced with AutoCAD Release 13 (and LT Release 3), "complex" linetypes are 2D: they can wiggle back and forth (within limits) and include text characters. Truth be told, that's all they are: text -- or, more accurately, shapes.

The complex linetype can consist entirely of 2D shapes, or can be mixture of 2D shapes and the 1D linetype codes -- the dash, gap, and dot we learned of earlier. The 2D shapes can be a combination of: (1) text characters from an SHX font file; and/or (2) shapes from an SHX shape file. AutoCAD comes with seven complex linetypes. Two of them -- the gas line and the hot water supply -- simply combine a dash and gap with the letters GAS and HW from the Standard text style (as defined by the Txt.Shx font file). Here is what the code looks like, as found in the LtypeShp.Lin 2D linetype definition file:

Much of this looks familiar to me, with the exception of the stuff between the square brackets. That allows the embedding of text in a linetype. Here's what it means:

Summing up, I can create a text-based linetype with a single parameter, such as ["HW"] or I can execute fine control over the font, size, rotation, and position with six parameters. Only problem is that Autodesk didn't include a "linetype editor" to let me visually tweak the parameters until they look right (MicroStation, for example, has a built-in linetype editor). Instead, it's a tedious back and forth between editing the LTypeShp.Lin file, then loading it into AutoCAD, and testing the linetype.

Embedding a Shape

But embedding text is not the last word in complex linetypes. Not at all. The other thing I can embed is a shape from an SHX file. AutoCAD old timers will remember a time -- say, about 15 years ago -- when shapes were the preferred substitute for blocks. Shapes were faster and more compact, a serious consideration when an 8MHz 8086 CPU was considered a hot machine and math chips were too pricey to afford. The use of shapes pretty much faded away as CPUs grew faster and the math chips became free. With the complex linetype, Autodesk found a new use for the languishing shape file: Release 13 and LT Release 3 introduced a new SHP file named LTypeShp.Shx. The file has the five shapes used by the other five complex linetypes. To use one of these takes three parameters:

3D Linetypes

Just kidding. There is no such thing as a 3D linetype in AutoCAD. If there were, I guess it might look like a bottle brush or the ribs on an electrical cord's strain relief.


Tailoring AutoCAD Part 15 | Part 16 | Part 17 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.