Search code examples
autocadautolisp

How to create my own line types using a shape file (.shx)


I'm trying to create my own line types using a shape file. My working sample has the following code.

*DEMO,Demolition X X X X X A,0,[DEMO,DEMO],-0.3

DEMO is a shape file. It was loaded as a shape is listed when using SHAPE command.

My proposed code is

*FNC-BARB,Barbwire ----X----X----X---- A,.125,-.1,[FNC-BARBWIRE,L:\AutoCAD\Linetypes\fnc-barbwire.shx,s=.1,x=-.1],-.1,1

I know AutoCAD has its own fence linetype using the text "X" but I wanted to use a shape file so that I can create other types of fence line types. I mapexport my shape (vector "X" (two crossed lines)). In MapExport for Object Type, I choose LINE instead of POINT, POLYGON, or TEXT. AutoCAD creates the .dbf, .idx, .shp, and .shx files. When I open a .shp file that works (DEMO.shp) it shows the following

*1,58,DEMO 4,250,4,4,3,199,3,31,3,143,002,9,(-64,64),(0,0),001,9,(127,-127),(1,-1),(0,0),002,9,(-127,0),(-1,0),(0,0),001,9,(127,127) (1,1),(0,0),002,9,(-64,-64),(0,0),001,4,143,4,31,4,199,3,4,3,250,0

as a Windows (CRLF) UTF-8 file.

The DEMO.shx gives the following

AutoCAD-86 shapes 1.0 ? DEMO úÇ À@ ÿ ÿ ÀÀ Çú EOF

When I open my file that doesn't work, it shows the following

' ªè
ÚHøü±¿ÚHøü±¿ÚHøü±?ÚHøü±? 8 ÚHøü±¿ÚHøü±¿ÚHøü±?ÚHøü±? ÚHøü±?ÚHøü±?ÚHøü±¿ÚHøü±¿ 8 ÚHøü±¿ÚHøü±¿ÚHøü±?ÚHøü±? ÚHøü±¿ÚHøü±?ÚHøü±?ÚHøü±¿

as an Unix (LF) ANSI file.

The FNC-BARBWIRE.shx file gives the following

' :è
ÚHøü±¿ÚHøü±¿ÚHøü±?ÚHøü±? 2 8 n 8

All of my files and .lin file are in the same folder. When I try to LOAD my shape, I get an error of

Command: LOAD Error reading shape file L:\AutoCAD\Linetypes\FNC-BARBWIRE.shx Error reading shape file \PWVMPF01\shares\Engineering\EBridge\AutoCAD\Linetypes\FNC-BARBWIRE.shx

When I try to load my .lin file I get "Bad definition...at line...of file". The following is the line.

A,.125,-.1,[FNC-BARBWIRE,L:\AutoCAD\Linetypes\fnc-barbwire.shx,s=.1,x=-.1],-.1,1

On some code that works, I tried to see what each number does to the line type. I know what's happening inside the brackets but I don't know what the numbers before and after.

*FNC-BARB,Barbwire ----X----X----X---- A,0.1,-.1,["X",STANDARD,x=-0.1,y=-.05,s=0.1],-0.05,0.1


Solution

    1. You need to have a valid shp/shx file. You can create it easily with StarShape application. Which You can find Here.
    2. Try to save shp/shx to the fonts directory of Your CAD application. If it works OK, then You can make tests by moving it to another location.

    Details of manual creating linetype definition, the meaning of each position in definition You can find on AfraLISP

    As far as I know, shp/shx may be used in 2 different contexts. One is the font and the other is the shapefile format as geospatial vector data format in GIS application. When you create GIS format data, You will have additional *.prj, *.dbf, and so on. But to use as a font it's enough to have just shp/shx file. Maybe the difference is in the version of the shapefile standard.