CUSTOMIZATION & LINETYPES

How to Create Custom Linetypes (.LIN) with Embedded Text or Shapes (MKLTYPE & MKSHAPE)

Complete guide to authoring custom utility and civil linetypes (--GAS--, --RW--, fence lines) in GstarCAD using ASCII .lin definitions or Express Tools MKLTYPE.

⚡ Quick Engineering Answer (TL;DR)

Define custom text linetypes directly in gcad.lin (or acad.lin) using the syntax A,dash,-gap,["TEXT",STYLE,S=scale,U=0,X=offset,Y=offset],-gap or generate them graphically in 10 seconds using the Express Tool MKLTYPE.

1. Root Cause & DWG Database Symptom Analysis

Civil, utility, and P&ID drawings rely heavily on complex linetypes embedding inline text letters (--- GAS ---, --- FIBER OPTIC ---, --- STORM ---) or geometric shapes (fences, retaining walls, railroad tracks). Understanding how GstarCAD parses .lin descriptors prevents upside-down text and missing `.shx` shape errors.

2. Step-by-Step Resolution in GstarCAD & AutoCAD

Step 1: Write a Portable ASCII Text Linetype Definition (.LIN)

Every `.lin` definition consists of two lines: a header line starting with *LINETYPE_NAME,Description and a pattern line starting with alignment code A. Positive numbers draw dashes, negative numbers lift the pen (gaps), and bracketed descriptors ["GAS",STANDARD,S=2.5,U=0.0,X=-2.5,Y=-1.25] embed inline text.

Step 2: Use U=0.0 (Upright Rotation) So Text Never Plots Upside Down

In older drawings using R=0.0 (Relative rotation), drawing a utility line from right-to-left caused the embedded text `GAS` to flip upside down! Replacing R=0.0 with U=0.0 (Upright) forces GstarCAD to keep the text right-reading regardless of polyline vertex direction.

Step 3: Graphical Creation via Express Tools MKSHAPE & MKLTYPE

Prefer not to write ASCII code? Draw your repeating segment on screen, run MKSHAPE (if embedding custom geometry) followed by MKLTYPE, pick a filename, name the linetype, and select the start/end points—GstarCAD compiles and loads the `.lin` file automatically.

3. System Variables & Command Diagnostic Table

Variable / Command Default / Target Value Diagnostic Function & Fix Behavior
U=0.0 (Upright) Modern Text Orientation Keeps embedded linetype text readable even on right-to-left lines
S=2.5 (Scale) Text Height Multiplier Multiplies by LTSCALE (or Text Style height if fixed)
X / Y Offsets Centering Shifts Centers the text string horizontally inside the negative pen-up gap
MKLTYPE / MKSHAPE Express Commands Compiles graphical geometry into .shp/.shx and .lin files visually

4. One-Click AutoLISP Fix Script (AutoLISP Programmatic Custom Utility Linetype Loader)

(defun c:MAKE-GAS-LTYPE ( / fn fp)
  (setq fn (strcat (getvar "TEMPPREFIX") "custom_util.lin")
        fp (open fn "w"))
  (write-line "*UTIL_GAS,Gas pipeline --- GAS --- GAS ---" fp)
  (write-line "A,25.0,-5.0,["GAS",STANDARD,S=2.5,U=0.0,X=-2.5,Y=-1.25],-8.0" fp)
  (close fp)
  (if (not (tblsearch "LTYPE" "UTIL_GAS"))
    (command "_.-LINETYPE" "_L" "UTIL_GAS" fn ""))
  (princ "\n[Linetype Engine] Loaded upright 'UTIL_GAS' linetype.")
  (princ)
)

Enterprise AC1032 Database Internals & Cross-Version Diagnostics

In multi-office engineering environments operating across GstarCAD 2027, GstarCAD Mechanical, GstarCAD Architecture, and legacy AutoCAD (2018–2027) seats, mastering How to Create Custom Linetypes (.LIN) with Embedded Text or Shapes (MKLTYPE & MKSHAPE) requires understanding how the underlying AC1032 DWG binary database serializes entity handles, symbol table records, and Named Object Dictionary (NOD) pointers.

1. DWG Header & Registry Persistence Scope

Variables and object properties fall into three persistence scopes: Drawing-Saved (DXF Header) variables that travel with the .dwg file to subcontractors, Registry-Saved (Profile .arg) settings that persist per Windows workstation user, and Session-Volatile states that reset on every launch unless locked inside acaddoc.lsp. Always verify persistence scope via SYSVDLG before issuing sheets to an ISO 19650 Common Data Environment (CDE).

2. Multi-Core Regeneration & Memory Hygiene

When processing large civil corridors, dense plant P&IDs, or 50-sheet architectural Xref trees, unpurged Registered Application IDs (REGAPP), orphaned DGN stroke dictionaries, and redundant annotation scales degrade spatial index (INDEXCTL = 3) lookup speed. Executing a pre-submittal AUDIT, command-line -PURGE → Regapps, and OVERKILL pass keeps file open times under 2 seconds on GstarCAD's multi-threaded graphics kernel.

3. Hybrid AutoCAD + GstarCAD Team Coexistence

Because GstarCAD reads and writes native AC1032 binary records without intermediate import/export translation, dynamic block grips, associative hatches, XData payloads (DXF groups 1000–1071), Paper Space viewport layer overrides (VPLAYER), and X.509 digital signatures round-trip losslessly between AutoCAD and GstarCAD seats on shared SMB/BIM cloud folders.

Production Field Verification Protocol (ISO 9001 / ISO 19650 Gate)

  1. Baseline Template Audit: Confirm that the active drawing inherits layer naming, linetype scales (PSLTSCALE = 1, MSLTSCALE = 1, LTSCALE = 1.0), and dimension styles from the enterprise .dwt / .dws standards file via CHECKSTANDARDS.
  2. Coordinate & Unit Integrity: Run -DWGUNITS or check INSUNITS, LUNITS, and MEASUREMENT to guarantee 1:1 metric (`mm`/`m`) or imperial (`in`/`ft`) block and Xref insertion scaling, with OSNAPZ = 1 preventing unintended 3D elevation drift.
  3. Submittal Packaging & Mobile Review: Lock all Paper Space viewports (`DisplayLocked = Yes`), bind or relative-path all external references via ETRANSMIT, and verify final plotted PDF/A lineweights (`ISO full bleed`) alongside DWG FastView mobile cloud markup links.

Related Engineering Guides, Courses & Troubleshooting FAQs

Continue building your CAD engineering mastery with these related GstarCAD Academy technical references:

Need 100% Native DWG Compatibility Without Subscription Lock-In?

Engineered by Suzhou Gstarsoft Co., Ltd. (SSE: 688657), GstarCAD 2027 opens, repairs, and plots AC1032 DWG files with full command and AutoLISP parity.

Download Free 30-Day Trial → All Troubleshooting FAQs AutoCAD Migration Hub