AutoCAD .LIN File Structure and Basic Pattern Syntax Explained
An AutoCAD LIN file is a small text library that can contain one or many linetype definitions. Understanding its two-line structure makes custom patterns easier to write, review, troubleshoot, and exchange.
This guide covers the basic numeric syntax only. Text strings, SHX shapes, and transformation parameters are handled in the text-linetype guide, the SHP/SHX guide, and the complex-code reference.
What Is an AutoCAD LIN File?
A LIN file is an external source file from which named linetype definitions can be loaded. After a definition is loaded, a copy is stored in the drawing’s linetype table. The source library is still needed when the definition must be reloaded, installed in another drawing, or maintained by a CAD manager.
Anatomy of a Linetype Definition
The Header Line
The first line begins with an asterisk, identifies the linetype name, and supplies a description:
*BORDER,Border __ __ . __ __ .
The Pattern Definition Line
The next line begins with the alignment code and describes the repeated sequence:
A,.5,-.25,.5,-.25,0,-.25
Why Every Definition Uses at Least Two Lines
The header provides the database name that users select. The pattern line provides the geometry. Combining both on one line or separating them incorrectly makes the definition invalid.
Understanding the Header Line
The Asterisk Before the Linetype Name
The asterisk marks the beginning of a new definition. It must be the first character of the header line. A semicolon would instead make the line a comment.
Linetype Names and Naming Restrictions
Use a concise unique name without a comma, because the comma separates the name from the description. Company prefixes and discipline identifiers reduce collisions when DWG content arrives from several sources.
Descriptions and Visual Pattern Previews
The text after the comma is for people, not for the pattern engine. It can state the use and include underscores or dots as a visual preview. Changing the preview does not change the displayed geometry.
Understanding the Basic Pattern Line
The A Alignment Code
The line begins with A, the supported aligned-pattern mode for standard AutoCAD LIN definitions. It helps the pattern begin and end with a drawn portion on ordinary line objects.
Positive Numbers for Drawn Segments
A positive value is a pen-down distance. For example, .5 draws a segment 0.5 drawing units long before the next descriptor is processed.
Negative Numbers for Blank Segments
A negative value advances without drawing. The absolute value is the gap length, so -.25 creates a 0.25-unit blank space.
Zero Values for Dots
A zero creates a dot. It occupies a pattern position but has no length. A following negative value is normally needed to create visible space after it.
How AutoCAD Repeats a Linetype Pattern
Calculating the Total Pattern Length
Add the absolute values of all distances in one cycle. In A,.5,-.25,0,-.25, the nominal cycle length is 1.0 drawing unit: 0.5 dash, 0.25 gap, a zero-length dot, and 0.25 gap.
Repeating the Pattern Along an Object
AutoCAD repeats the cycle along the measured object path. The displayed size is then affected by the relevant global, object, model-space, and paper-space settings explained in the existing LTSCALE, CELTSCALE, and PSLTSCALE/MSLTSCALE articles.
Handling the Pattern Near Object Endpoints
The aligned mode adjusts pattern placement so ordinary lines begin and end with a drawn segment. Objects shorter than the cycle can therefore display an incomplete or apparently continuous result.
LIN File Formatting Rules
Commas and Decimal Separators
Use commas to separate descriptors and a period as the decimal point in portable definitions. Do not use a locale-specific decimal comma, because it is already the LIN field separator.
Spaces and Line Breaks
Spaces around numeric values are usually unnecessary. The critical line break is the one between the header and its pattern. Do not wrap a long definition automatically in a text editor.
Uppercase and Lowercase Characters
Use consistent case for names, style references, and shape references. Even when a product treats some identifiers case-insensitively, consistent case makes reviews and cross-platform testing safer.
Comments and Blank Lines
A line beginning with a semicolon is a comment. Use comments to record units, author, revision, and dependencies. Blank lines can separate groups, but they should not interrupt one definition’s header-pattern pair.
Storing Multiple Linetypes in One LIN File
Separating Definitions
Place each new header and its pattern after the preceding definition. A blank line and a comment header can make a large library easier to navigate.
Avoiding Duplicate Names
Do not define the same name twice in the same managed library. Duplicate names in different files are also risky because a drawing may already contain an older definition when the user loads the new file.
Organizing Definitions by Discipline
Small organizations may use one company file. Larger teams often maintain a core library plus architecture, MEP, civil, survey, or client-specific files. The governance options are detailed in the company linetype-standard guide.
Valid and Invalid LIN Syntax Examples
Valid Dashed Pattern
*CADLT_DASHED,Dashed __ __ __
A,.50,-.25
The positive dash and negative gap form a complete repeating cycle.
Valid Dash-Dot Pattern
*CADLT_DASHDOT,Dash dot __ . __ .
A,.50,-.20,0,-.20
Invalid Header Example
CADLT_DASHED,Dashed __ __ __
The asterisk is missing, so the line does not start a definition.
Invalid Pattern Example
A,.50 -.25
The comma between the dash and gap is missing. This can trigger a Bad Definition error.
Basic LIN Syntax Reference Table
| Element | Purpose | Example |
|---|---|---|
*NAME |
Starts the header and names the definition. | *CADLT_DASHED |
| Comma after name | Separates the name from the description. | ,Dashed line |
A |
Starts the aligned pattern. | A,.5,-.25 |
| Positive number | Drawn segment. | .5 |
| Negative number | Gap. | -.25 |
0 |
Dot. | 0 |
; |
Starts a comment line. | ; Metric utilities |
Topics Covered Separately in Complex Linetype Coding
Text and Shape Descriptors
Complex definitions add bracketed descriptors that reference a text style or a compiled SHX shape. These components are always treated as complete elements and introduce dependency and orientation issues not present in simple patterns.
Rotation, Scale, and Offset Parameters
Parameters such as A=, R=, U=, S=, X=, and Y= control the embedded component. They are explained without repeating basic syntax in the complex linetype code reference.
