How to Extract and Export a Custom Linetype from a DWG File

A DWG can contain a custom linetype even when the original LIN file is missing. The loaded drawing-table record preserves enough information to inspect the pattern, but recovery is not always the same as retrieving the original source file.

Simple dash-gap definitions can often be rebuilt exactly. Complex text and shape patterns may depend on text styles, fonts, or SHX files that are not embedded in the drawing.


What Linetype Information Is Stored in a DWG?

The drawing stores the loaded name, description, pattern elements, and data needed to display the definition. That is why a simple custom linetype can continue to appear after the source LIN file is moved. The stored record can be inspected manually or through AutoLISP.


What May Still Be Missing from the Drawing

Original LIN File

The exact comments, formatting, library organization, and revision history of the source text file are not recovered merely by opening the DWG. A reconstructed definition should therefore be documented as a recovered version.

External SHX Shape File

A complex pattern can reference a compiled SHX shape. If that file is missing, the drawing may show warnings or an incomplete pattern even though the linetype table still contains the reference.

Required Font File

Text-based linetypes reference a text style, and that style references a font. Font substitution can make the recovered pattern look different from the original.


Identify the Custom Linetype

Find Its Name

Select an affected object and inspect its effective Linetype value. If it is ByLayer, inspect the layer. Record the exact name, including prefixes and separators.

Find the Layers and Objects Using It

Sort layers by linetype and search for direct object overrides. This confirms whether one definition is used consistently or whether several similar names exist.

Determine Whether It Is Simple or Complex

A pattern containing only dashes, gaps, and dots is simple. Repeated words or symbols indicate a complex definition and a likely dependency on a text style, font, or SHX file.


Inspect the Linetype Pattern

Review the Pattern Length

Draw a long horizontal sample with object scale 1 in a controlled drawing and measure one cycle. Remember that global and viewport-related scale settings can alter the displayed size.

Identify Dashes, Gaps, and Dots

Measure the repeated distances and compare several cycles. A zero-length dot is easier to recognize under a light lineweight.

Identify Embedded Text or Shapes

Inspect the displayed component and the text styles or support warnings in the drawing. A word points to a text descriptor; a custom graphic often points to SHX.


Recreate a Simple Linetype Manually

Measure the Pattern

Use a test object whose effective scale is understood. Measure each drawn and blank distance, then divide out any known display scale to recover source values.

Write the Header

Create a unique recovered name or preserve the original only when the definition is confirmed:

*CADLT_RECOVERED,Recovered dash-gap pattern

Write the Pattern Definition

Translate drawn distances to positive numbers and gaps to negative numbers:

A,.50,-.25,.10,-.25

Load the file in a blank drawing and compare it with the source DWG.


Extract Linetype Table Data with AutoLISP

Read the Linetype Table Record

Core AutoLISP can locate a named table record:

(setq rec (tblsearch "LTYPE" "CADLT_GAS"))
(if rec (princ rec))

This confirms the stored record and exposes group-code data for further processing.

Retrieve Pattern Elements

A complete routine must interpret the table record and associated linetype data correctly. Separate element lengths, flags, text or shape references, offsets, rotation, and scale rather than printing the raw list as if it were valid LIN code.

Write the Data to a LIN-Compatible File

Generate a header and a valid comma-separated definition, escape quoted text correctly, and record unresolved dependencies. Test the exporter against known simple and complex source files before trusting it on an unknown project.


Extract a Complex Linetype

Identify Text Descriptors

Record the embedded string, referenced style, rotation mode, component scale, and X/Y offsets. Recreate the required text style in the test drawing before comparing results.

Identify Shape References

Record the shape name and SHX filename. The drawing can preserve the reference while the actual compiled resource is absent.

Locate or Rebuild Missing Dependencies

Search project transmittals, support folders, archived standards, and consultant packages. Rebuilding an SHX shape from visible output is possible only as an approximation unless the original source is found.


Validate the Exported LIN File

Load It in a Blank Drawing

A blank drawing prevents an older stored definition with the same name from masking errors in the recovered file.

Compare It with the Original

Use lines of the same length and effective scale. Compare cycle length, endpoints, text or symbol position, and direction behavior.

Test Different Scales and Directions

Test horizontal, vertical, reversed, diagonal, curved, short, and long objects, then compare model space, paper space, and PDF output.


Rename and Document the Extracted Definition

Add a company prefix, source note, recovery date, unit convention, and unresolved dependency note. Do not silently distribute a reconstructed approximation under an official client name.


Limitations of Linetype Extraction from DWG Files

  • The original source comments and file organization are not recovered.
  • Font files and SHX resources may be absent.
  • Displayed measurements can be distorted by scale settings.
  • A complex external resource may need to be rebuilt rather than extracted.
  • Application-specific object styles are not ordinary LIN definitions.
  • Always compare the recovered result with a trusted source drawing and use a complete sharing package for future deliveries.


Related Linetype Guides