Welcome to CADVANTAGE’s No Nonsense, Quick Start, Step by Step tutorial for AutoCAD Script.

This tutorial is part of the CAD-CAM @ Home scheme currently available in the city of Aurangabad in India.

The tutorial is a Goodwill Gesture for all AutoCAD users who take pains to go out of way and learn new things.

To learn more about computers in general and CAD CAM CAE in particular as detailed below, you may enroll for the
CAD++ [ CAD @ Home ] program at :

CADVANTAGE ( where AutoCAD is taught FREE )
C 2 - 6, N 7, CIDCO,
Opp. Onkar Gas, Behind Swami STD,
Aurangabad 431003
India
Ph : 0240 - 480767
Email : CadGuruCool@yahoo.com
Webpage : www.geocities.com/CadGuruCool



Tutorial : Writing AutoCAD Script Files


Step 1

It is assumed that you are familiar with the basics of some version higher of AutoCAD R12.

The code that we will undertake should work in ACAD R12 through ACAD 2002.

The target for this tutorial is to write a script file that will draw an A4 size sheet with border, margins and the title block in AutoCAD as shown in figure to the right.

Step 2

What is a script ?

Just as a playwright does the script for a drama, and the actors follow and act accordingly on the stage, we can write a script file using notepad that AutoCAD will follow and act accordingly.


.
Step 3

What goes inside a AutoCAD script file ?

Any AutoCAD command can be written in a script file.

Also, a .lsp file can be loaded and AutoLISP routines therein be called.


.

Step 4

How does script file differ from a AutoLISP program ?

In AutoLISP, we can have the program pause for user interaction, whereas a script executes continuously from start to end unless otherwise interrupted by the user with the Esc key.

In AutoLISP programming, we can include iterations and loops, while this is not possible with scripts with no pun intended.

Although a script can load a AutoLISP file and make a call to the functions therein, the control cannot be passed back to the script after the AutoLISP program terminates.

Step 5

We want to write a script for AutoCAD that will draw an A4 size sheet with borders, margins and the title block rectangle.

We will use Notepad to write the script.

Click the Start button and Select Run.
Step 6

A dilaog box will appear.

Type notepad.

Click OK or press Enter on the keyboard
Step 7

The rules for writing a script file is simple - only one word on a line and no spaces at the end of the word.

As soon as Notepad is fired, start typing the code as shown in figure on the right (top).

The first word in the script is to begin the line command.

Press Enter

The next word is the start point coordinate for the sheet border ie. 0,0 and the next point is 297,0 written on the next line.

This way we complete drawing four lines with the last line back to 0,0

At this stage, the AutoCAD line command is still running, so we leave a blank line after 0,0.

To leave a blank line, we must press the Enter key at the keyboard which is passed to AutoCAD which terminates the line command.

This creates our sheet border.

Next, we zoom extents the rectangle so that the remaining show is visible till the last row.

The remaining story need not be narrated to intelligent AutoCAD users, exept the following :

Save the file as Tutorial.scr where, the extension .scr is important.

To use the script, type script at the AutoCAD Command: prompt as shown in the figure on the right (bottom). The standard file open dialog box will appear where you can select the tutorial.scr file.



Step 8

Want to dig deeper
into AutoCAD ?

Call CADVANTAGE Now !!! Ph : 0240 - 480767 in Aurangabad.


Dig deep till you reach the other side of the globe - Only at CADVANTAGE