AutoCAD Tutorial

AutoCAD 2004 Customization Tutorial: Shapes with Straight Lines, Part 1

June 11, 2003

Shapes are defined within Shape files. Shape files are text files with SHP extension. If you are not familiar with compiling shape files and/or loading and inserting shapes read the following tutorial:

AutoCAD 2004 Customization: Using Shapes

1. Download the following drawing file. The file will be used to extract shape information [Figure 1]

Note: If you are using an earlier release of AutoCAD download:

Figure 1 - Click on image to enlarge

2. Open the file in AutoCAD.

3. Disable all running OSnaps but Intersection.

4. The dotted lines are used to first build the shape in AutoCAD. You will use the drawing to calculate the proper codes for drawing shapes. The lines and numbers to the right show you the main direction angles for shapes. You can use them as help.

5. Draw a 11 square.

6. In command line, type Notepad and then press Enter twice. The Notepad window appears.

7. In Notepad window type the proper code for the shape header:



  • Every header name starts with an asterisk (*).

  • The first number is the shape number. The valid values lie between 1 and 255.

  • The second number shows the number of codes you have entered to define the shape.

  • SQUARE is the name of the shape. The name should be typed with uppercase letters otherwise will be ignored.

8. On the second line type proper codes to define the shape. Figure 2 may be helpful:



  • The start point is P1 [Figure 2]. The drawing direction is shown with some arrows [Figure 2].

  • 001 means pen down or rather draw lines. This code is optional as the pen is by default down. To make pen up you should use 002.

  • In 010 the first 0 means you are entering a hexadecimal number (base 16). The 1 shows the size of the straight line which equals 1. The last 0 shows the direction code. Since the line is parallel to positive X direction the value is 0 [Figures 1 and 2].

  • In 014 you are drawing a unit line in vertical direction. The 0 means the values are entered as hexadecimal numbers. 1 means the length is equal to 1 and 4 means the direction is vertical [Figures 1 and 2].

  • The 018 and 01C draw straight unit lines in 8 and C directions respectively.

  • The last code (0) shows the termination of drawing.

  • I have entered 6 codes to define the shape. Thus the second number on shapes header is equal to 6.

Figure 2

9. Press Enter to insert a blank line. Make sure there is no space between codes.

10. Save the file as "stlines.shp".

11. In AutoCAD start a new drawing.

12. Invoke Compile command. The Select Shape or Font File dialog box appears [Figure 3].

Figure 3 - Click on image to enlarge

13. Locate and open "stlines.shp".

14. Use the LOAD command to load the "stlines.shx" into the new drawing.

15. Use the SHAPE command and insert the shape in the drawing area. Congratulations! You managed to create and insert your first shape.

16. Close the new drawing file without saving.

17. In "R16_shapes.dwg" draw a parallelogram [Figure 4].

Figure 4 - Click on image to enlarge

18. Enter the proper code to define the parallelogram as a shape [Figure 5].

Figure 5


  • In the header line, 102 is the shape number, 6 is the number of codes used to define the shape and PARAL is the name of the shape.

  • In the description line, 001 means pen down, 020 means draw a 2 units line in 0 direction, 012 means draw a unit line in 2 direction, and 0 means terminate drawing.

19. Add the code of figure 6 to define the octagon shown in figure 7.

Figure 6

Figure 7

Note: You can enter the shape description in multiple lines.

20. Verify that the code in figure 8 defines an isosceles triangle. Why?

Figure 8

About the Author

Alireza Parsai is the founder of He is a mechanical engineer with more than 12 years experience with AutoCAD. Alireza is an Autodesk Authorized Author, the AutoCAD consultant for Al Khawarizmi Institute, a contributing editor for Augiworld magazine, a writer for CAD Digest, an instructor for AUGI Training Program, and an elected speaker for Autodesk University 2002. He has written 7 books in Farsi, 3 booklets in English, and more than 30 articles for different magazines and newsletters. You can reach him at or visit his website

More CAD Corner tutorials >>