Programming Course

Chapter 1

Introduction

CAD Software AutoCAD

1.1 Introduction

In a few years, every architect in Switzerland will have a computer aided design system in the office. Knowing a CAD package and having experience in using it will be one of the basic requirements of every graduating architectural student. The success of CAD in recent years has also propagated some of its serious shortcomings, in that no CAD program

It is therefore not the intent of this course to train you in a particular CAD program or design view but to prepare you for the difficult task of designing and changing CAD programs for your personal use or to needs specified by other architects.

The emphasis of this course will be on principles. All exercises have the purpose of illustrating one particular aspect of design computing.

1.2 Computer Operations - Getting Started

All the machines in the lab are connected with each other and to services like printers and plotters via a network. You can work on any machine that is available. You need a login name and a password in order to use any machine. When you are finished working, you should logout of your account and turn off the monitor. See Appendix A for details of this procedure.

In order to effectively use a computer system, some basic concepts need to be understood. A computer system is made up of a number of physical components, collectively known as hardware. Hardware is controlled and directed by a set of instructions known as software or computer programs. Software programs can be obtained from various sources and can be installed on various machines or hardware.

An operating system is a collection of software programs designed to work on specific hardware configuration. When you log into your account, you interact with the operating system. At present, in cluster E29, we have Silicon Graphics Indys running the IRIX (UNIX) operating system. In order to make working with computers easier, a set of programs may be installed on top of the operating system, known as window manager, e.g., IndigoMagic on the SGIs. As a result, each command or process you start is displayed in a rectangular region on the screen, called a window. Windows can be closed temporarily in which case they will collapse into an icon, or windows can be quit if a process is finished and no longer needed. Commands can be entered by typing them in at the keyboard or by a series of movement and clicking actions with a mouse. Some useful commands and actions are explained in Appendix A.

In some cases, you can enter a command and its result will be some information displayed on the screen, e.g., if you type date, the current date and time are displayed. Other commands start a process in which you can generate additional information that can be stored and retrieved later. For example, an editor program lets you create text files which can be stored and manipulated. Thus there are computer programs and data you generate with such programs, both are referred to as files and may be stored separately with different file names. To work on a data file, you need to start the program which created that file, and then load in that data file for further processing.

Programs and data files are stored in directories and subdirectories organized in a hierarchical fashion. You can move up and down a file system using operating system commands like cd, and delete, rename, or copy files using other commands like rm, mv, cp (see Appendix A for further details).

1.3 AutoCAD - Basic Concepts

AutoCAD is one of the many interactive graphics programs which allows representation and manipulation of objects in the three dimensional coordinate space. A crucial concept to understand is the object model supported by an application program like AutoCAD. An object like a cube may be represented by drawing only the edges of the cube. If the program cannot represent surfaces stretching between edges, it will generate only a wire-frame model of objects. If a program can generate surfaces but cannot represent material space filling the cube, it will generate only a surface model of objects. If a program can properly represent material space of an object, it can generate a solid model of objects. AutoCAD is capable of representing objects as wire-frame, surface and solid models subject to some restrictions.

In order to become familiar with AutoCAD, a small number of commands are introduced in this section. To represent objects in an application, a number of primitive shapes like lines, circles, polygons, etc. are provided for drawing tasks. Occasionally, a shape that is already drawn needs some changes, e.g. moving it from one place to another. These actions are known as editing or modifying functions. An object can be displayed in plan, elevation or axonometric projection, and be looked at from varying distances. These are referred to as viewing control functions. You may want to save the objects so that they can be retrieved and modified later on; these are the file related functions. Quite often you may need to suspend, undo an action or need help for command completion. These are the utility or assist functions described under SOS. There are a number of additional tasks that you can perform with AutoCAD. These can only be learned with time and practice. Additional (and quite detailed) information is available in the AutoCAD manual copies in the lab.

Setting Up

Start AutoCAD by typing acad in any shell window. Once AutoCAD is properly loaded, you will see a graphic window with a screen menu and some pull-down menus at the top. At the bottom, you see a prompt command: in a small window. Here is where you can enter AutoCAD commands as well as LISP expressions for evaluation. If you hit the F1 key, a bigger window comes to the foreground on your screen. This is the same command: prompt window which was only partially visible earlier.

Type new on the command line, click on Discard Changes and enter a file name when prompted for a drawing name. To avoid compatibility problems between AutoCAD and UNIX, use only lower case letters.

When you are finished with the following sections, remember to quit AutoCAD, and log out.

1.3.1 Draw

Various kinds of shapes and objects are available under the Draw menu. Some useful commands under this menu are:

Line To draw a straight line from one point to another. A sequential set of points creates a connected series of line elements.

Pline To draw a polyline element made up of one or more connected straight lines and arcs. Each subcomponent of a polyline may have a different line width. Pline generates elements in only the x-y plane of the current coordinate system.

3Dface To draw a surface defined by a number of edges in three dimensional space. Use this command if realistic models are to be generated. Enter the vertices in counter-clockwise fashion.

Circle To draw a circle in a variety of ways using radius, diameter, arcs, chords, etc. as parameters.

1.3.2 Construct - Modify

To transform a drawing element, a number of operations are provided under the Construct and Modify pull-down menus.

Move To move one or more element(s) from one location to another.

Rotate To rotate one or more element(s) in reference to a point by some rotation angle.

Scale To enlarge or reduce one or more element(s) by some scale factor.

Copy To make a copy of one or more element(s) and place them in another location.

Array To make copies of one or more element(s) and place them in either a rectangular (rows and columns) configuration, or polar (circular) configuration.

1.3.3 View

In AutoCAD, regardless of the particular view in which objects are drawn and displayed, the program stores them in true three-dimensional space. By changing the particular viewing position, other views of the elements may be generated and displayed. These commands are available under the View menu.

Vpoint When AutoCAD is started, by default, you are working in a plan view. This command enables you to specify another view using x-y-z values.

Zoom To adjust the current viewing distance.

Pan To shift the "drawing" view, i.e. visible portion of a drawing, without changing the viewing distance or moving objects.

Redraw To get rid of construction markers generated intermittently.

Regen To completely recalculate the displayed model.

Hide To remove elements that are not visible from a given view point and to generate a realistic image of the drawing elements.

1.3.4 File

All the work you do in AutoCAD can be saved in a file so that you can retrieve it later on and make changes, plot it out, etc. All AutoCAD drawing files have the extension dwg as in 01_name.dwg and 02_name.dwg. You will see the current file name displayed at the top of the AutoCAD window.

If you start a new drawing in AutoCAD, you need to input only the file stem, e.g. 01_name or 02_name. The file extension will be provided by the program.

If you want to work on an existing drawing file, input only the file stem, e.g. 01_name or 02_name. AutoCAD will search for and load the appropriate file.

Save To save all the information in the current drawing file. If you want to save it under a different name, enter a new file name. This operation does not stop or quit AutoCAD, hence you can do further work if you wish.

Exit Choose Save Changes... to save all the work under the current file name and stop AutoCAD. Otherwise, if you choose Discard Changes, any changes made after the last time the file was saved, will be discarded. In this case, your drawing file will contain only those drawing elements present when the file was last saved.

1.3.5 SOS - Assist

^C Cancel a command in progress by holding down the keys labeled Control and C at the same time. This interrupts any ongoing command (in most cases) and displays an empty command line.

Help To get on-line help on a topic or command. To find out more about it, type help and ? If you do not want to see additional information displayed, remember to press ^C.

Undo To undo one or more commands executed previously.

Redo To redo the last command that was undone by the undo command. Unlike undo, this can only be used to recall one step.

1.3.6 Other Commands

Other useful drawing commands include: layer, block, insert, text, dtext, dim, mspace, pspace. They are explained more fully in the AutoCAD manuals available in the Lab. If you need help with any of these commands, request help from a TA.

1.4 Macros

Bring the AutoCAD text window into the foreground by hitting the F1 key. With this larger window available, proceed with the following section.

When a command is selected and executed in AutoCAD, e.g. line, both the command and the arguments supplied are echoed in the command: prompt area. Another way to accomplish the same actions is to type in the command and arguments as macro expressions. For example, suppose a line is to be drawn from point (0,0) to point (8,0) to point (8,8) to point (0,8) and back to the starting point, you can do this interactively as follows:

command: line
Start Point: 0,0
To Point: 8,0
To Point: 8,8
To Point: 0,8
To Point: c

This will generate four connected lines, forming a square shape. You could type in the coordinates for points or select them on screen using a cursor. Alternately, you can type in the following line at the command: prompt exactly as shown with quote marks:

(command "line" '(0 0) '(8 0) '(8 8) '(0 8) "c")

This too will generate the same graphic elements as earlier. This (LISP) expression is a shorthand way of expressing a desired series of actions without touching the mouse or moving the cursor. Further, a series of such commands can be collected and placed in a separate file. When such a file is loaded into an AutoCAD drawing, the LISP interpreter will evaluate each expression and execute each command just as if it were entered interactively. A series of such expressions collected in a file are known as macros, and they have two principal advantages. First, macros allow you to automate some routine drawing set up and generation tasks. Second, since macros are LISP expressions, you can use all capabilities the LISP programming language provides you with.

Open a Jot window, type in the above macro, and save the file with extension .lsp (for example, name.lsp). Load the file into AutoCAD by typing: (load "name") at the command prompt. This should generate the same results as earlier. Remember, if you make any changes to the macro file, you have to save it and load it again into AutoCAD to see the effects of those changes.

There is more to writing and making use of macros, e.g. naming macros, using AutoCAD commands as part of LISP functions, executing macros from screen and pull-down menus. These topics are explained in the following lectures.

1.5 Exercise 1 - Macros

This exercise is meant to test your understanding of AutoCAD commands, command format and arguments using small macros which can be successfully executed in AutoCAD.

  1. Draw a closed polyline; specify a width and color. Construct the corresponding macro in a text editor.
  2. Generate a polar array of the polyline element drawn earlier; specify the angle to fill 360 and rotate object as it is copied. Construct and add the corresponding macro in the text editor.
  3. Change the thickness of all the elements. Note that you can do this by selecting elements in a window or by incorporating this step at an earlier point in the program. Add the corresponding macro to the text editor.
  4. Select a view point for your drawing and add the corresponding macro.
  5. Remove hidden lines. Add the corresponding macro.
  6. Erase all elements in the drawing. Save the set of macros in a file.
  7. Load the file into AutoCAD and check the result. If there are any important differences, compare your macros with the output from your previous actions. Edit the macros accordingly, save the file and try again.
  8. Create a snapshot of the result.
  9. Submit both the snapshot and the macro file.