AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Custom Linetypes

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.


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

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


Easy hey! Now let's have a look at creating out own custom 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 :

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]:

Select "Enter" to complete the process.

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.


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

Select "Load". The Load dialog will appear :

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 :


To create your own linetype definition is very simple. First locate your newly created "Afralisp.lin" file, and open it using Notepad. It should look like this :

;
;AfraLisp Linetype definitions
;Written November 2001
;
*dashdot3,_ . . . _ . . . _ . . .  _
A,0.5,-0.25,0,-0.25,0,-0.25,0,-0.25

Yours will not have the first two lines as I added them later. Just precede any comments you wish to add with ";".
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.

To Page No II

 
The AutoLisp/Visual Lisp/VBA Resource Website

Copyright © 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website