AfraLISP - Learn AutoLISP for AutoCAD productivity

Creating Custom Linetypes

by Kenny Ramage

There are two different ways of creating linetypes within AutoCAD. You can write your own linetype definition file, or you can use AutoCAD's built in function to create it for you. In this tutorial we'll look at both methods. Let's start with the AutoCAD built in function first.

Before we start though, let's have a look at what a linetype is.

A linetype is a series of positive and negative numbers that tell a plotter how long to lower or raise a pen. Positive numbers lower the pen, and negative numbers raise it. The normal length of a dash is .5; a dot is 0. e.g. 0,-.25 would produce a series of dots. The first 0 produces the dot; the -.25 raises the pen .25 of a unit. The series then repeats itself.

dotted linetype

A dash-dot would be .5,-.25,0,-.25.

dash dot linetype

A dashed line would be .5,-.25.

dashed linetype

Easy hey? Now let's have a look at creating out own custom linetype.

Creating a Linetype

Let's say we want a linetype to be dash, dot, dot, dot.
The format would be .5,-.25,0,-.25,0,-.25,0,-.25. and we'll call the linetype "dashdot3". Fire up AutoCAD and enter the following at the command line :

Command: -linetype

Current line type: "ByLayer"

Enter an option [?/Create/Load/Set]: c

Enter name of linetype to create: dashdot3

After pressing <Enter> the following dialog will appear :

Create or Append Linetype File

Enter Afralisp as the file name and select "Save".

Creating new file

Descriptive text: _ . . . _ . . . _ . . . _

Enter linetype pattern (on next line):
A,.5, -.25, 0, -.25, 0, -.25, 0, -.25

New linetype definition saved to file.

Enter an option [?/Create/Load/Set]: <Enter>

We could have appended the linetype definition to an existing file, but in this case we've created a new file. If you want to change an existing linetype definition, just create a new linetype, giving it the same name as the old one. AutoCAD will ask you if you want to overwrite the existing linetype; answer yes. You can then enter the new definition and description.

Note : Complex linetypes cannot be created using the "Linetype" command at the command line.

Loading the Linetype

To load and set your new linetype, enter "Linetype" at the command line. The "Linetype Manager" dialogue will appear :

Linetype Manager

Select "Load". The Load dialog will appear :

Load or Reload Linetypes

Select "File" and then "AfraLisp.lin". Next select "dashdot3" linetype and then "OK"

In the "Linetype Manager" dialogue, select "dashdot3" again and then "Current" followed by "OK". Your "dashdot3" linetype should now be loaded and set. Draw a line. It should look like this :

the dashdot3 linetype

To create your own linetype definition is very simple. First locate your newly created "Afralisp.lin" file, and open it using Notepad. The location of the file is not obvious but should be something like:
C:\Users\UserName\AppData\Roaming\Autodesk\AutoCAD 2010\R18.0\enu\Support\Afralisp.lin

Once opened, it should look like this :

Afralisp.lin in Notepad

You can add comments to the file if you wish. Just precede any comments with ";". The first line of the file is a comment. As you can see, your linetype definition consists of 2 lines. The first line consists of "*" followed by the linetype name followed by the description separated by a comma ",". The description is optional and can be a sequence of dots, spaces and dashes or a comment such as "A Dashed Line followed by 3 Dots". If you omit the description, do not put a comma after the linetype name. If you include a description, it should be no more than 47 characters long. (Why? Who knows!)

The second line starts with the "alignment" field which you specify by entering "A". AutoCAD only supports one type of alignment field at this time so you will always enter "A". Next comes a comma "," followed by your linetype definition.

Pretty easy hey? On the next page we'll have a look at complex linetypes.

Creating Complex Linetypes