How to Create and Compile SHP/SHX Shapes for AutoCAD Linetypes
A shape-based linetype can repeat a graphic that cannot be represented by text alone: a zigzag, small box, circle-like mark, directional symbol, or simplified utility marker. The graphic is stored in a compiled SHX shape file and referenced by the LIN definition.
The workflow has three separate assets: editable SHP source, compiled SHX output, and the LIN pattern that places the shape. For simpler labels, use text inside a custom linetype instead.
Why Use Shapes in Complex Linetypes?
Shapes provide a repeatable symbolic mark without inserting hundreds of individual blocks. They are suitable for compact stroke-based graphics that must follow a line path. They are not a replacement for detailed blocks, fills, images, or multi-line assemblies.
Text-Based Linetypes vs. Shape-Based Linetypes
When Text Is Sufficient
Use text when an abbreviation communicates the meaning clearly. GAS, WATER, ELEC, and FENCE are easier to maintain as text than as custom outline shapes.
When a Custom Shape Is Required
Use a shape when the standard calls for a graphic symbol, when a font character is unavailable, or when text would be ambiguous. Keep the symbol simple enough to remain recognizable at the smallest plotted scale.
Understand SHP and SHX Files
The Editable SHP Source File
An SHP file contains readable shape-definition instructions. It is the source that should be archived and version-controlled. Keep comments explaining the shape number, name, intended origin, and design size.
The Compiled SHX File
AutoCAD reads the compiled SHX resource when it displays the linetype. The SHX file must be available through a support path or another resolvable location on every workstation.
How the LIN File References the Shape
The bracketed descriptor identifies both the shape name and the SHX filename:
[BOX,cadlt_shapes.shx,S=.10,R=0.0,X=-.05,Y=-.05]
The shape name must exist inside that compiled file. The LIN file does not embed the SHX data.
Plan the Linetype Symbol
Choose a Simple and Readable Shape
Reduce the graphic to the minimum strokes needed for recognition. Tiny details increase file complexity and often merge together when plotted.
Define the Shape Size
Draw the source at a known nominal size. Record that size so the S= value in the LIN descriptor can be tuned systematically instead of by trial and error alone.
Select the Shape Origin
The origin is the point that AutoCAD places on the line path before offsets are applied. A poorly chosen origin forces large X/Y corrections and makes rotation difficult to predict.
Test the Symbol at Plotting Scale
Print or export a test sheet at the smallest and largest intended scales. A shape that looks clear while zoomed in may become a dark blob or disappear in the final PDF.
Create the Shape Geometry in AutoCAD
Draw the Source Geometry
Draw the symbol with simple line and arc strokes around the intended origin. Keep all geometry in one plane and remove construction objects before creating the shape.
Simplify Lines and Arcs
Reduce unnecessary vertices and replace approximated curves with clean arcs where possible. A compact stroke definition is easier to compile, rotate, and display.
Remove Unsupported Objects
Explode or redraw unsupported content such as hatches, regions, dimensions, splines, text, and complex blocks. The final shape should consist only of geometry that the shape-creation workflow can translate.
Why Polylines with Width Result in Errors
Why Shape Definitions Do Not Preserve Polyline Width
Shape instructions describe pen movement. They do not preserve filled polyline width as a solid band, so a wide source object cannot become a genuinely filled shape.
Converting Geometry to Lines and Arcs
Remove the width, explode or redraw the centerline, and confirm that the visible result still represents the intended symbol.
Removing Fills, Hatches, and Unsupported Objects
Delete fills and hatches rather than assuming the compiler will simplify them. For a filled repeated graphic, use a block, hatch, or specialized object as discussed in the linetype-limitations guide.
Create the SHP Shape Definition
Assign a Shape Name
Use a short unique name such as BOX, TREE, or SLOPEMARK. The exact name will be referenced by the LIN file, so document and preserve its spelling.
Assign a Shape Number
Each shape in a file requires a numeric identifier. Maintain a registry in the source file or library documentation so two definitions do not accidentally reuse the same number.
Define Pen-Up and Pen-Down Movements
Pen-down movement draws a stroke; pen-up movement changes position without drawing. A well-planned origin and stroke order reduce unnecessary repositioning instructions.
Define Direction and Distance Codes
Shape code uses compact movement instructions. Build and verify the symbol in small steps. When the shape fails to compile, isolate the last added movement rather than rewriting the entire definition.
Compile the SHP File into an SHX File
Run the COMPILE Command
Start COMPILE and select the SHP source. AutoCAD checks the shape syntax and attempts to create a compiled SHX file.
Select the SHP Source File
Compile the controlled source copy, not a temporary file from an email or download folder. The output should be placed in the same managed library or a designated build folder.
Verify That the SHX File Was Created
Confirm the timestamp and filename, then add the output location to the support path. A LIN definition can be syntactically correct and still fail to display if it references an older or missing SHX file.
Reference the SHX Shape in a LIN File
Enter the Shape Name
The first field in the descriptor must match the compiled shape name exactly:
[BOX,cadlt_shapes.shx]
Enter the SHX Filename
Use the filename, not one user’s absolute path. AutoCAD searches the configured support locations, making the same LIN file easier to deploy on Windows and macOS.
Set Scale, Rotation, and Offsets
Add S=, R= or another rotation mode, and X/Y offsets. The parameter behavior is explained in the complex-code reference.
*CADLT_BOX,Box symbol ---- [] ---- [] ----
A,.50,-.15,[BOX,cadlt_shapes.shx,S=.10,R=0.0,X=-.05,Y=-.05],-.15
Add the SHX File to the Support Search Path
Place the SHX in a controlled support folder and add that folder in AutoCAD Options or AutoCAD for Mac Application Preferences. See the support-path guide for mixed-platform deployment.
Load and Test the Shape-Based Linetype
Test Different Line Directions
Draw objects in opposite directions and check whether the symbol orientation is acceptable. Relative rotation follows the path; upright or absolute strategies may be needed for directional graphics.
Test Different Object Lengths
Confirm that short objects have enough room to reach the shape descriptor. If not, create a compact variant rather than shrinking the symbol until it becomes illegible.
Test Model Space and Layout Output
Compare model space, several viewport scales, plot preview, and PDF. Shape linework can look acceptable on screen but merge under a heavy lineweight.
Common SHP and SHX Compilation Errors
Duplicate Shape Numbers
Two shapes in one file cannot safely share an identifier. Keep a simple number register and recompile after correcting the duplicate.
Invalid Shape Codes
An unsupported or malformed movement instruction stops compilation. Reduce the source to the last known working shape, then add instructions back one group at a time.
Missing SHX File
If the LIN loads but the symbol is missing, confirm the exact filename and support path. Use the Bad Definition and missing-SHX guide for the full diagnosis.
Incorrect Shape Name
The SHX file can exist while the requested shape name does not. Compare the LIN descriptor with the compiled source and watch for spelling or revision differences.
Unsupported Polyline Geometry
Remove width, curved approximations, and unsupported objects from the source geometry. Recreate the shape from clean lines and arcs.
Files to Include When Sharing the Linetype
- The DWG that uses the loaded definition.
- The source LIN file for reloading and maintenance.
- The compiled SHX shape file required for display.
- The editable SHP source for internal library maintenance.
- A readme stating the support folder and approved scale tests.
Package project delivery files with the process in the eTransmit, LIN, and SHX sharing guide.
