General Software

AutoLISP Solutions: Automated drawing coversheet

1 Apr, 2002 By: Tony Hotchkiss

Add custom toolbars to your AutoLISP program interfaces.


Julie Conley requested a routine to insert any one of four template coversheets into new and existing drawings. If an existing drawing has a coversheet, the routine provides an option not to insert one. AutoCAD uses templates for new drawings, but they are cumbersome to add to existing drawings. The coversheets that Ms. Conley uses are for architectural drawings, but you can modify the solution for wider applicability.

This AutoLISP solution comprises COVERSHEET.LSP, COVERSHEET. DCL, and ACADDOC.LSP. To load any number of AutoLISP programs, simply add the (load) function to your ACAD.LSP file, if it exists. Later versions of AutoCAD, such as AutoCAD 2000 and 2002, can open many files simultaneously. In these cases, the ACAD.LSP file has a counterpart, called ACADDOC.LSP, for multiple documents.

How to use COVERSHEET.LSP
Download the required files from Cadalyst's CAD Tips site and save them in AutoCAD's Support directory. If you already have a file named ACADDOC.LSP in your Support directory, append the contents of the downloaded ACADDOC. LSP file to the end of the existing file:

(if (not coversheet)
(load "coversheet")
)
(coversheet)
(princ)
Figure 1. Dialog box for Coversheet command.

Adding these lines automatically loads the Coversheet program and executes it. In a multiple-drawing environment, the ACAD.LSP file executes only once, at the beginning of the session, whereas the ACADDOC.LSP file executes every time you open a drawing. You can force the ACAD.LSP file to execute with every drawing by setting a system variable or the user options, but that is more complicated than using ACADDOC.LSP.

The Coversheet program inserts one of the four drawings, named NH24X36.DWG, NH30X42.DWG, R24X36.DWG, and R30X42.DWG, that Ms. Conley requested. These drawings should also exist in the AutoCAD Support folder.

When you start a new drawing or open an existing drawing, you see the dialog box shown in figure 1. There you choose to insert any one of the four coversheet files indicated, or none. Figure 2 shows the "New home E-size" coversheet selected in the dialog box.

Figure 2. Coversheet inserts the sheet selected in the dialog box.

Programming notes
I used the AutoCAD 2000 Visual LISP editor to write the program, but it should also work in AutoCAD 2002. If you use earlier versions of AutoCAD, you may be able to substitute the ACAD.LSP file for the ACADDOC.LSP file. The Coversheet program works in either a single- or multiple-document environment (controlled by system variable SDI).

The program starts with a modified version of my usual system variable management functions, followed by the dialog box driver function (coversheet). This function gets the value of the radio button and calls the function (set-cs). (set-cs) assigns the value of the global variable CSHEET:

(defun set-cs (val)
(setq csheet
(cond
((= val "NHD") "NH24X36")
((= val "NHE") "NH30X42")
((= val "RD") "R24X36")
((= val "RE") "R30X42")
((= val "none") "none")
) ;_ cond
) ;_ setq
) ;_ defun

After the routine closes and unloads the dialog box, it uses the CSHEET variable to insert the drawing that the variable represents. The drawing is zoomed to its extents (figure 2). As always, contact me with comments or requests.


About the Author: Tony Hotchkiss


AutoCAD Tips!

Lynn Allen

Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's Tips & Tricks Tuesdays free e-newsletter and we'll notify you every time a new video tip is available. All exclusively from Cadalyst!
Follow Lynn on Twitter Follow Lynn on Twitter


Latest News from Cadalyst Partners
Feed
Autodesk Gallery Powers of Design Exhibit: 10**15 Cat's Eye Nebula   23 May, 2013

I work out of our office on One Market Street in San Francisco. My standup-desk is right across from our Gallery at One Market. One of our newer...More>>Read more It's Alive in the Lab blog posts>>

Feed
Load ‘Em Up! Stackers, Conveyors, and Advanced Assembly   23 May, 2013

Mineral resources come out of the ground and are then processed into energy, fertilizer, steel, and so on. We all kind of knew that already. But...More>>Read more PTC Creo blog posts>>

Feed
Excel Hyperlinks & Document Management Tricks   22 May, 2013

Do you have to keep track of a lot of different folders and files? Do you wish you peers could open the correct Revit file? Are you tired of having...More>>Read more BIMbuilder blog posts>>

Feed
New Certification Logos And Certificate Designs Available   23 May, 2013

Every few years we undergo a redesign of our logos and certificate backgrounds which is done to keep them looking fresh.  This week we released the...More>>Read more SolidWorks Blog posts>>

Feed
Cool Tools of Doom n’ Stuff: Episode 22   23 May, 2013

Have the cicadas been hassling you all week? Perhaps its just time you try a new bean paste? Either way, we’ve got you covered with...More>>Read more SolidSmack blog posts>>

Poll
What type of input device (besides the keyboard) do you use at your primary CAD workstation?
Standard mouse
Trackball mouse
Programmable mouse
3D navigation device
Pen/tablet
Multiple devices
Submit Vote




Considering Wide Format Printing Solutions?
Four FREE White Papers Available:






Subscribe Cadalyst Newsletters