You are free to use the information listed here, but it is copyrighted works and are not public domain. You may not sell, lease, or mass-redistribute this information on disk or electronically. You may not post this information online (including web sites, ftp sites, bulletin boards, and other online services) for public viewing, and you may not publish in print for public viewing without prior written consent of DotSoft.
DISCLAIMER: DOTSOFT DISCLAIMS ANY AND ALL LIABILITY FOR ANY DAMAGES ARISING OUT OF THE USE OR OPERATION, OR INABILITY TO USE ANY INFORMATION AVAILABLE HERE. FURTHERMORE, BY USING THIS INFORMATION YOU AGREE TO HOLD DOTSOFT HARMLESS FROM SUCH CLAIMS. DotSoft makes no warranty, either expressed or implied, as to the fitness of this information for any particular purpose. All materials are to be considered �as-is�, and use of any information should be considered as AT YOUR OWN RISK!
Adding Customization, how to add user lisp and routines to your system.
Excel Scripting, making an AutoCAD Script file from Excel.
Raster Plotting, how to create bitmaps from your drawings.
Text Linetypes, how to create linetypes with embedded letters.
Users often want to add miscellaneous lisp routines to their system, having them automatically loaded and available at all times. The intentions of this procedure is to allow the customization to survive a reinstallation or upgrade of AutoCAD.
Autoloading of these files will be controlled by a special file called ACAD.LSP, which will load the custom routines. Note that AutoCAD does not create or use this file.
- Create a separate 'unique' subdirectory such as C:\CADSTUFF using Windows Explorer.
- Add the directory C:\CADSTUFF to the AutoCAD Support File Search Paths. For those unfamiliar:
A) Issue the OPTIONS command.
B) Click the Files tab.
C) Expand the Support File Search Path section.
D) Choose the Add button.
E) Choose the Browse button.
F) Navigate to and choose the C:\CADSTUFF folder.
- Place all your LSP and related files into the C:\CADSTUFF directory.
- Using Windows Notepad (or another ascii editor) create a new file named ACAD.LSP in the C:\CADSTUFF directory containing a load statement for each routine to be loaded.
An example is shown in the following lines.
Now whenever you start/restart AutoCAD, it will locate the ACAD.LSP file and load it. Loading of ACAD.LSP will in turn load your designated files. Since these files are loaded, you will be able to initiate these added commands by typing the command defined in each routine.
You may also wish to add buttons or aliases to speed up the initialization of these commands.
Scripting from Excel
This procedure will walk through the process of using Microsoft Excel to create script files to be read into AutoCAD. Tabular information is often present in the spreadsheet that needs to be transferred to AutoCAD. The example explained here is a table of layer names with colors and linetypes. It could quickly be adapted to use point coordinates to create inserts. This example provides Excel specific explanations, but users of other spreadsheets should be able to adapt the instructions to their particular product. The following instructions will reference the next example.
The goal is to populate column D with concatenated values appropriate to pass to the AutoCAD command line.
- Make cell D1 current.
- Enter this expression in cell D1.
="N "&TRIM(A1)&" C "&TRIM(B1)&" "&TRIM(A1)&" LT "&TRIM(C1)&" "&TRIM(A1)
It is very important that the spaces be included. Note that just as in the command line layer command, we must pass the layer name after each designation such as color to tell AutoCAD to assign that color only to the current layer. This explains the multiple references to A1.
- Copy that expression down to all the valid lines.
- Highlight the entire column D and copy it to the clipboard.
- Choose File/New to create a new empty sheet.
- Choose Edit/Paste Special, choose Values.
- Insert a blank row at the top of the file and enter this:
- Choose File/Save As, choose Save As Type, then choose Text (OS/2 or MS-DOS)(*.TXT).
- Enter the script filename such as D:\PATH\FILENAME.SCR.
- When prompted that the selected format does not support multiple sheets, choose Ok.
- Excel has the file locked down in the operating system, and AutoCAD can't even run it, so we must close it first. Choose File/Close, choose No to the next dialog. This was just a temporary workbook anyway.
- Back in AutoCAD, make any preliminary settings as necessary, such as loading linetypes.
- Issue the SCRIPT command, choose your script. When its done you will may have to press enter once.
- Check the layer table. It should be populated with the information from Excel.
Creating Text Linetypes
This procedure will walk through the process of creating your own text linetypes, utilizing the capability introduced with AutoCAD R13. You might be surprised at how much you can do with this simple customization, especially when combined with the Windows Wingding Truetype font.
Note that not all details or principals of creating linetypes are presented here. You should consult the AutoCAD customization guide for full details.
Where definitions are stored:
While linetype definitions can be stored in any file with the LIN extension, you will probably find it easiest to make your changes to the ACAD.LIN file. This file is found in your AutoCAD SUPPORT directory. This approach does involve some recommended backups. First it would be convenient to backup the original ACAD.LIN file. Second after you get the new linetypes established it would be a good idea to backup the file again, to protect against overwriting if AutoCAD is reinstalled.
The easiest approach:
One simple way to create an additional text linetype is to copy one of the examples in the ACAD.LIN file. We have reproduced a small portion of it here.
*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----
*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--
Notice that the primary difference between these two definitions is the letters used (HW -vs- GAS) and the last number on the second line. The value was incremented by 0.05 to accommodate the extra character. You may need to experiment with this value to determine the right number to produce the desired gap for the text. A starting point is 0.1 times the number of characters, as the added WATER linetype works well with a value of -.5.
*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--
*WATER_LINE,Water line ----WATER----WATER----WATER----WATER----
The need for UNICODE:
In our next copy we also desire to have a quotation mark for inches, such as in a water line of 6" to be drawn as W-6". Since the linetype definition uses the quotation marks as a delimiter, we can't simply add another quotation mark. UNICODE comes to the rescue with the ability to express these as well as other characters not available on the keyboard. A small sampling includes:
- \U+0022 = Quotation Marks
- \U+00B0 = Degree symbol
- \U+00B1 = Plus/minus tolerance symbol
- \U+2205 = Diameter dimensioning symbol
Next example appears as:
*WATER_LINE,Water line ----WATER----WATER----WATER----WATER----
*6IN_WATER,6in Water line ---- W-6 ---- W-6 ---- W-6 ----
A,.5,-.2,["W - 6\U+0022",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.55
With many fonts you should be able to use %%34 for the quotation marks.
The need for Styles:
Notice that all of the examples we have used so far have referenced the STANDARD text style, which will always be defined in the drawing. If you would like to use a different text style in your text linetype you need to make sure that the style is defined in the drawing before you try to load the linetype, otherwise you will receive the unwelcome "Bad Definition Error".
In consideration of this, it would be a good idea to add the needed styles to your prototype/template. You may even want to open your prototype, add the desired text styles and even establish the text linetypes needed. Once saved, new drawings based on this prototype/template will automatically provide the text linetypes ready to use, you won't even have to load them. As there is a small amount of overhead associated with each linetype, you would want to be conservative and only add those you would expect to use most of the time.
WingDings expands the possibilities:
You have the ability to use any font in your text styles which in turn can be referenced in your text linetypes. So why not take advantage of the useful symbols contained in the various Windows WingDing fonts. You will also see some useful symbols in the SYMBOLS.TTF and other truetype fonts.
To see the contents of these fonts and identify the appropriate character value, you will need to enlist the help of the Windows Character Map tool. This comes with all versions of Windows but may not be installed by default. From the Windows Start button, check under Accessories and maybe System Tools.
If you don't have this program [CHARMAP.EXE] you will need to use the Add/Remove Programs applet of the Windows Control Panel to add it. It will be in the System Tools section of the Windows Setup tab. Once you get Character Map you will be ready to continue. The application looks like this with the WingDings font set current.
Notice that the bold right arrow is currently highlighted and the keystroke is shown in the lower right hand corner. So to add our fancy Wingding text linetype we would first need to create the WINGDING style based on the Windows WINGDING.TTF font. Then we would add the linetype.
*RIGHT_ARROW,Right arrow ---- > ---- > ---- > ---- > ----
To achieve the special character enclosed in the quotes, hold down the Alt key on the keyboard while you enter the numbers 0232 on the number pad, then release the Alt key.
When the text linetype is loaded and used, it can produce attractive results, such as the following example.
Note that with this arrow text linetype the arrow will generally point in the direction that the geometry was drawn. However ARC's will always display pointing counter-clockwise. For these situations simply generate the left arrow linetype and change the geometry's linetype.
PLINEGEN plays a part:
You may notice that on polylines that contain arcs that the annotation always wants to read counter-clockwise even if you reverse the polyline. That is because the the linetype generation flag for that polyline needs to be turned on. ToolPac users simply use the ToolPac>Polyline>Ltype Gen>On option and select the affected polylines.
To show the stacked centerline symbol in your linetypes, use the lower case 'q' in conjunction with the GDT.SHX font. Use the same procedure discussed to set this up.
Plotting to Raster Files
A popular inquiry from AutoCAD users is how to plot a drawing to a raster file (or bitmap/picture). This is often in response to the need to provide a 'picture' of the drawing without actually providing the DWG, or perhaps a drawing is to be displayed in a web page.
First is the simple to use (but less control) command called BMPOUT. It creates a Windows Bitmap .BMP file, appropriate for Paintbrush but not ready for a web page. It captures the whole drawing viewport so center your drawing as well as possible before issuing the command. The following procedures can be used to 'plot' your drawing to a raster file.
- Choose File > Plotter Manager.
- Choose 'Add-A-Plotter Wizard'.
- Choose Next, then Next again (accepting My Computer).
- Under Manufacturers, choose 'Raster File Formats'.
- Under Models, choose 'Portable Network Graphics PNG'.
(details on why below)
- Choose Next until the Finish button becomes available.
- Issue the Plot Command.
- On the Plot Device Tab, choose the PNG output created.
- Choose the Properties button, and choose the output resolution desired.
- In the lower right corner, specify the path and filename to create.
- Switch to Plot Settings tab, specify the window and complete the plot to file.
- Issue the PREFERENCES command.
- Choose the Printer tab.
- Choose the New button.
- Choose Raster File Formats.
- Enter a Description such as 'Raster Plot'.
- Choose an output resolution.
(Consider the resolution of the target device, if the output is to a display, you may want to use 1024x768 or less)
- Choose a raster format.
(None of the choices are ready for web output, but the Windows BMP format is easily converted to such a format with raster converters).
- Choose Monochrome or Color.
(If its a single color line drawing, choosing mono can make for a smaller file, otherwise 256 color is your best choice)
- Specify the background color.
(The default is 0=black, acceptable for display but would consume much ink/toner if output. So consider color 255 for light white.)
- Hit enter for 'Change Anything'
- Choose OK to close the dialog.
- Issue the PLOT command.
- Choose the 'Device & Default Selection' button.
- Choose the 'Raster Plot' setup previously.
- Choose the 'File Name' button and designate a file.
- Proceed to plot as normal, the output going to the file.
You may wonder why the PNG file was chosen. It is a clean highly compressed format. In comparison, the JPG (JPEG) format is absolutely NOT a desireable format for representing linework in raster format. While JPEG is fine for photographs, it is a 'lossy' compression and will produce noticable 'snow' on line drawings, especially diagonal lines.
The PNG file is your best choice for raster output. It is very compact in size and is a 'loseless' compression. It can be displayed by all 'current' web browsers as well.