AutoCAD Script Files

What is an AutoCAD script file?

Background:
To graphically depict outputs of a program, alternatively, you can plot the outputs in AutoCAD software instead of using Excel chart. Here, you can work further with charts drawing with either a 2D or 3D model. The main advantage of AutoCAD is because this software is specifically built for composing drawings.



Meaning:
Script file meant here is a text file that contains a sequence of commands executed by AutoCAD. The sequence of commands can be made on a worksheet or in VBA to speed up and simplify the process of writing and executing the commands. The script file is made by a word processor such as Win. Notepad or Microsoft Word in ASCII format and given with a .scr file extension.

Creating Scripts:
There are two ways of creating scripts: worksheet way or VBA way. Examples:





















The Code:

Private Sub CommandButton1_Click()
Dim myFile As String
myFile = Cells(2, 5)

Open myFile For Output As #1

For i = 1 To 3
Print #1, "line " & Cells(2 + i, 1) & "," & Cells(2 + i, 2) _
& " " & Cells(3 + i, 1) & "," & Cells(3 + i, 2)
   Write #1, 'an empty line for pressing Enter
Next i

Close #1

End Sub

The use of a script file for creating AutoCAD drawings in civil engineering field is quite popular because of its simplicity. You do not need to have advanced knowledge and great computer resources to produce any applications. Both Excel and AutoCAD are almost found in any computer owned by a civil engineer and became must have software for civil engineers worldwide, thus, any applications created by Excel-VBA-AutoCAD are applicable to most computers.

Example of the use of a script file:

Calculating and presenting allowable pile bearing capacity versus depth based on SPT N values from a number of boreholes.




This article is a chapter section of the book "An Introduction to Excel for Civil Engineers"