- •Contents
- •Contents at a Glance
- •Acknowledgments
- •Preface
- •Is This Book for You?
- •How This Book Is Organized
- •How to Use This Book
- •Doing the Exercises
- •Conventions Used in This Book
- •What the Icons Mean
- •About the CD-ROM
- •Other Information
- •Contacting the Author
- •Foreword
- •Credits
- •About the Author
- •Summary
- •AutoCAD’s Advantages
- •Comparing AutoCAD and AutoCAD LT
- •Starting AutoCAD and AutoCAD LT
- •Creating a New Drawing
- •Using the AutoCAD and AutoCAD LT Interface
- •Creating a New Folder
- •Using the Interface
- •Saving a Drawing
- •Closing a Drawing and Exiting from AutoCAD and AutoCAD LT
- •Summary
- •Creating a New Drawing from a Template
- •Working with Templates
- •Opening a Drawing with Default Settings
- •Opening an Existing Drawing
- •Using an Existing Drawing as a Prototype
- •Saving a Drawing Under a New Name
- •Summary
- •The Command Line and Dynamic Input
- •Command Techniques
- •Of Mice and Pucks
- •Getting Help
- •Summary
- •Typing Coordinates
- •Displaying Coordinates
- •Picking Coordinates on the Screen
- •Overriding Coordinate Settings
- •Locating Points
- •Summary
- •Choosing Unit Types
- •Drawing Limits
- •Understanding Scales
- •Creating a Title Block
- •Specifying Common Setup Options
- •Customizing with the MVSETUP Command
- •Using the Setup Wizards
- •Summary
- •Using the LINE Command
- •Drawing Rectangles
- •Drawing Polygons
- •Creating Construction Lines
- •Creating Rays
- •Summary
- •Drawing Circles
- •Drawing Arcs
- •Creating Ellipses and Elliptical Arcs
- •Making Donuts
- •Placing Points
- •Summary
- •Panning
- •Using the ZOOM Command
- •Using Aerial View
- •Saving Named Views
- •Working with Tiled Viewports
- •Using Snap Rotation
- •Understanding User Coordinate Systems
- •Creating Isometric Drawings
- •Summary
- •Editing a Drawing
- •Selecting Objects
- •Summary
- •Copying and Moving Objects
- •Resizing Commands
- •Using Construction Commands
- •Creating a Revision Cloud
- •Hiding Objects with a Wipeout
- •Double-Clicking to Edit Objects
- •Grips
- •Editing with the Properties Palette
- •Selection Filters
- •Groups
- •Summary
- •Working with Layers
- •Changing Object Color, Linetype, and Lineweight
- •Working with Linetype Scales
- •Importing Layers and Linetypes from Other Drawings
- •Matching Properties
- •Summary
- •Drawing-Level Information
- •Object-Level Information
- •Measurement Commands
- •AutoCAD’s Calculator
- •Summary
- •Creating Single-Line Text
- •Understanding Text Styles
- •Creating Multiline Text
- •Creating Tables
- •Inserting Fields
- •Managing Text
- •Finding Text in Your Drawing
- •Checking Your Spelling
- •Customizing the spelling dictionary
- •Summary
- •Working with Dimensions
- •Drawing Linear Dimensions
- •Drawing Aligned Dimensions
- •Creating Baseline and Continued Dimensions
- •Dimensioning Arcs and Circles
- •Dimensioning Angles
- •Creating Ordinate Dimensions
- •Drawing Leaders
- •Using Quick Dimension
- •Editing Dimensions
- •Summary
- •Understanding Dimension Styles
- •Defining a New Dimension Style
- •Changing Dimension Styles
- •Creating Geometric Tolerances
- •Summary
- •Creating and Editing Polylines
- •Drawing and Editing Splines
- •Creating Regions
- •Creating Boundaries
- •Creating Hatches
- •Creating and Editing Multilines
- •Creating Dlines
- •Using the SKETCH Command
- •Digitizing Drawings with the TABLET Command
- •Summary
- •Preparing a Drawing for Plotting or Printing
- •Creating a Layout in Paper Space
- •Working with Plot Styles
- •Plotting a Drawing
- •Summary
- •Combining Objects into Blocks
- •Inserting Blocks and Files into Drawings
- •Managing Blocks
- •Creating and Using Dynamic Blocks
- •Using Windows Features
- •Working with Attributes
- •Summary
- •Understanding External References
- •Editing an Xref within Your Drawing
- •Controlling Xref Display
- •Managing Xrefs
- •Summary
- •Preparing for Database Connectivity
- •Connecting to Your Database
- •Linking Data to Drawing Objects
- •Creating Labels
- •Querying with the Query Editor
- •Working with Query Files
- •Summary
- •Working with 3D Coordinates
- •Using Elevation and Thickness
- •Working with the User Coordinate System
- •Summary
- •Working with the Standard Viewpoints
- •Using DDVPOINT
- •Working with the Tripod and Compass
- •Displaying a Quick Plan View
- •Shading Your Drawing
- •Using 3D Orbit
- •Using Tiled Viewports
- •Defining a Perspective View
- •Laying Out 3D Drawings
- •Summary
- •Drawing Surfaces with 3DFACE
- •Drawing Surfaces with PFACE
- •Creating Polygon Meshes with 3DMESH
- •Drawing Standard 3D Shapes
- •Drawing a Revolved Surface
- •Drawing an Extruded Surface
- •Drawing Ruled Surfaces
- •Drawing Edge Surfaces
- •Summary
- •Drawing Standard Shapes
- •Creating Extruded Solids
- •Drawing Revolved Solids
- •Creating Complex Solids
- •Sectioning and Slicing Solids
- •Using Editing Commands in 3D
- •Editing Solids
- •Listing Solid Properties
- •Summary
- •Understanding Rendering
- •Creating Lights
- •Creating Scenes
- •Working with Materials
- •Using Backgrounds
- •Doing the Final Render
- •Summary
- •Accessing Drawing Components with the DesignCenter
- •Accessing Drawing Content with Tool Palettes
- •Setting Standards for Drawings
- •Organizing Your Drawings
- •Working with Sheet Sets
- •Maintaining Security
- •Keeping Track of Referenced Files
- •Handling Errors and Crashes
- •Managing Drawings from Prior Releases
- •Summary
- •Importing and Exporting Other File Formats
- •Working with Raster Images
- •Pasting, Linking, and Embedding Objects
- •Summary
- •Sending Drawings
- •Opening Drawings from the Web
- •Creating Object Hyperlinks
- •Publishing Drawings
- •Summary
- •Working with Customizable Files
- •Creating Keyboard Shortcuts for Commands
- •Customizing Toolbars
- •Customizing Tool Palettes
- •Summary
- •Creating Macros with Script Files
- •Creating Slide Shows
- •Creating Slide Libraries
- •Summary
- •Creating Linetypes
- •Creating Hatch Patterns
- •Summary
- •Creating Shapes
- •Creating Fonts
- •Summary
- •Working with the Customization File
- •Customizing a Menu
- •Summary
- •Introducing Visual LISP
- •Getting Help in Visual LISP
- •Working with AutoLISP Expressions
- •Using AutoLISP on the Command Line
- •Creating AutoLISP Files
- •Summary
- •Creating Variables
- •Working with AutoCAD Commands
- •Working with Lists
- •Setting Conditions
- •Managing Drawing Objects
- •Getting Input from the User
- •Putting on the Finishing Touches
- •Summary
- •Understanding Local and Global Variables
- •Working with Visual LISP ActiveX Functions
- •Debugging Code
- •Summary
- •Starting to Work with VBA
- •Writing VBA Code
- •Getting User Input
- •Creating Dialog Boxes
- •Modifying Objects
- •Debugging and Trapping Errors
- •Moving to Advanced Programming
- •Summary
- •A Final Word
- •Installing AutoCAD and AutoCAD LT
- •Configuring and Using Workspaces
- •Configuring AutoCAD
- •Starting AutoCAD Your Way
- •Configuring a Plotter
- •Discovering AutoCAD and AutoCAD LT
- •Accessing Technical Support
- •Autodesk User Groups
- •Internet Resources
- •System Requirements
- •Using the CD-ROM with Microsoft Windows
- •What’s on the CD-ROM
- •Troubleshooting
- •Index
962 Part VI Customizing AutoCAD
3.The w then specifies the Width option. The space following it is like pressing Enter. The PEDIT command then displays the Specify new width for all segments: prompt.
4.The macro then specifies 0.1. The space after it is like pressing Enter again. The PEDIT command then issues the Enter an option [Close/Join/Width/Edit vertex/Fit/ Spline/Decurve/Ltype gen/Undo]: prompt.
5.The macro then uses a semicolon, which is used to specify pressing Enter at the end of a menu macro. This ends the command.
Customizing Tool Palettes
Tool palettes give you quick access to blocks, hatches, and commands. I cover tool palettes in Chapter 26. You can perform some customization directly on the tool palettes themselves. Here I explain the procedure for customizing the tool palettes using the Customize dialog box.
To customize tool palettes, choose Tools Customize Tool Palettes to display the Customize dialog box, shown in Figure 29-11. The current tool palettes are listed. Remember that each tab on the Tool Palette window is considered a separate tool palette.
Figure 29-11: The Tool Palettes tab of the Customize dialog box.
Use the Customize dialog box to customize tool palettes as follows:
Change the order of the tool palette tabs: Select one of the tabs in the Tool Palettes list and drag it up or down. You can also move the tabs directly on the Tool Palette by right-clicking the tab name and choosing Move Up or Move Down.
Create a new tool palette: Right-click and choose New Tool Palette. Enter a name and press Enter. To create a new tool palette on the palette itself, right-click anywhere on the palette and choose New Tool Palette.
Rename a tool palette: Click the palette’s name to select it, and then click it again so that you see a border around the name. Enter a new name and press Enter. To rename a tool palette on the palette itself, right-click on the tab’s name and choose Rename Tool Palette.
Chapter 29 Customizing Commands, Toolbars, and Tool Palettes |
963 |
Delete a tool palette: Select the tool palette, right-click and choose Delete. In the Confirm Tool Palette Deletion dialog box, which warns you that deletion is permanent unless you first export the tool palette, click OK to delete the tool palette. You can also right-click any tool palette and choose Delete Tool Palette.
Import a tool palette or group: Right-click a palette or group and choose Import. In the Import Palette dialog box, locate the XTP file and click Open.
Export a tool palette group: Right-click a palette or group and choose Export. In the Export Palette dialog box, choose the location for the file. You can change the name if you want. The tool palette is saved as an XTP file. Click Save.
Organize tool palettes into groups: In the Palette Groups area, right-click and choose New Group. Enter a name for the group and press Enter. From the Tool Palettes list on the left side of the dialog box, drag one or more tool palettes under the group name on the right, as you see in Figure 29-11. Note that the tool palettes now come with a large number of dynamic blocks.
Summary
In this chapter, I covered the basics of customizing AutoCAD and AutoCAD LT. You started to customize by:
Creating command shortcuts (aliases) in the acad.pgp or aclt.pgp file
Creating your own toolbars that can contain any command sequence that you need
Customizing tool palettes, including importing, exporting, and creating groups
In the next chapter, you read about how to create macros with script files.
|
|
|
Creating Macros and Slide Shows with Script Files
Script files are like macros that you create in your word processor or spreadsheet. They automatically execute a series of commands.
You can use script files to automate plotting, set up a drawing, clean up a drawing, create a slide show, or do any repetitive task.
If you need to put together just a few commands that you run only once, you may want to consider creating a menu item or toolbar button instead. Chapter 29 explains how to customize toolbars, and Chapter 33 explains how to customize menus.
Creating Macros with Script Files
A script file contains a list of commands and options. To create a script file, you need to think out the commands that you want to execute, as well as their options and prompts. Then you create the text for the script file. Script files have the following characteristics:
They must use the .scr file name extension.
They are text-only (ASCII) files.
They must use command-line syntax only.
Creating the script file
You can create the script file using a text editor, such as Notepad. For early practice with script files, type each command on its own line. A blank space is equivalent to pressing Enter. End each line by pressing Enter (also called Return), without extra blank spaces. If you need two returns, one after another, at the end of a line, use a blank line for the second return. Every space is meaningful; getting those spaces and blank lines right is probably the hardest part of creating a script file. One technique is to start your script files in a word processing program that can display nonprinting characters (blank spaces and returns). You can either save the script file in text format or copy it into Notepad. Some tips to help you create successful script files with the least aggravation are as follows:
Before creating the script file, go through the steps once using only the command line. Turn off the Dynamic Input feature for this purpose, because it doesn’t always include all of the command line content. (Click the DYN button on the status bar.)
30C H A P T E R
In This Chapter
Automating commands with script files
Creating slide shows
Creating slide libraries for menu customization
966 Part VI Customizing AutoCAD
If you use any dialog boxes that ask for files, set the system variable FILEDIA to zero (off) before experimenting with the commands that you’ll use in the script file. This setting lets you practice the keystrokes without opening dialog boxes. You can also practice using the version of the command with the hyphen in front of it (such as -layer); however, in most cases, you don’t need the hyphen in the actual script file.
Note |
Script files automatically run as if FILEDIA were off, even if it’s set to 1 (on). |
For commands that require inputting text such as layer names or file names, enclose the names in quotation marks. Then, for the next use of Enter, press Enter and go to the next line in the script instead of using a space. Otherwise, AutoCAD may misinterpret a space as a space in the layer name or file name, rather than an Enter.
Place comments in your script file to explain what you’re doing. A comment is any line that starts with a semicolon.
Keep Notepad open as you work. When you’ve completed a set of keystrokes that you want, open the AutoCAD Text Window (press F2), select the command string that you want, right-click, choose Copy, switch back to Notepad, and paste. Then cut out all of the prompts, leaving only the keyboard entry. You’ll probably have to readjust the spaces between the words.
You can press End to check for blank spaces at the end of a line. Pressing Ctrl+End moves the cursor to the end of the document; this is useful for checking for extra spaces and lines at the end of a script.
Remember, you can open Notepad from within AutoCAD by typing Notepad at the command line. At the File to edit: prompt, press Enter to open a new file. (In AutoCAD LT, you need to start Notepad from Windows.)
Another option is to write down what you type at the command line. As you write, use an underscore to represent each space. It’s very hard to remember that you left three spaces between two words unless you see three underscores. Of course, when you create the script file, you must use spaces, not underscores.
As soon as you complete the script file, save it with any name that is meaningful to you, plus an extension of .scr.
Here’s an example of a script file that draws a series of circles:
circle 2,2 1.5 circle 6,2 1.5 circle 10,2 1.5 circle 14,2 1.5
This script file starts the CIRCLE command, specifies a center point, and specifies a radius, four times. The results are shown in Figure 30-1.
Figure 30-1: Running a script file created this drawing.
Chapter 30 Creating Macros and Slide Shows with Script Files |
967 |
Running a script file
You can run a script file from within a drawing. Use this technique when you want the script to apply only to that drawing. However, you can also start a script within a drawing, then close the drawing and continue on to open and run the same script for other drawings.
You can also run a script file when loading AutoCAD or AutoCAD LT. You would do this when you want the script file to apply to more than one drawing. For example, you could use script files in the following situations:
You want to use a script file to set up every drawing that you open. Although the script file applies to only one drawing at a time, you use it on a different drawing each time.
You want to use a script file to clean up a list of drawings in one batch, such as thawing all layers on all of the drawings in a folder.
Running a script file from within a drawing
If you want the script to apply only to the current drawing, then start the script from within your drawing. To run a script from within a drawing, follow these steps:
1.Choose Tools Run Script. This opens the Select Script File dialog box.
2.Choose the script file that you want.
3.Click Open. AutoCAD or AutoCAD LT runs the script file.
Running a script when loading AutoCAD or AutoCAD LT
To run a script when loading AutoCAD or AutoCAD LT, change the target expression that Windows uses to open AutoCAD or AutoCAD LT. The easiest way to do this is to use the shortcut to AutoCAD or AutoCAD LT on your desktop and modify the target there. Right-click the AutoCAD or AutoCAD LT shortcut and choose Properties. Click the Shortcut tab, shown in Figure 30-2.
Figure 30-2: The Shortcut tab of the AutoCAD 2006 Properties dialog box.
968 Part VI Customizing AutoCAD
The Target text box displays the command expression that Windows uses to open AutoCAD or AutoCAD LT. Don’t make any change to the current expression — just add to it. If you’re using AutoCAD LT, substitute aclt.exe for acad.exe and your AutoCAD LT program location in the following examples. The format for starting a script file is:
drive:\path\acad.exe drive:\path\drawingname.dwg /b script_file
For example, if your current target reads C:\Program Files\AutoCAD 2006\acad.exe and you want to open a drawing named ba-349.dwg in c:\drawings and run a script file named pre-plot.scr, your target should read:
“C:\Program Files\AutoCAD 2006\acad.exe” c:\drawings\ba-349.dwg /b pre-plot
You don’t need to add the .scr extension after the script file name. Long file and folder names that contain spaces must be enclosed in quotation marks, both in the target and in the actual script file. You need to include the full path of the drawing. If the script file is not in the support file search path, include the entire path. For example:
“C:\Program Files\AutoCAD 2006\acad.exe” “c:\aec\drc\Dobbs Ferry Apts.dwg” /b c:\aec\drc\cleanup
If you want to start a new drawing, you might want to specify a template. In the preceding format, replace the drawing file name with:
/t template_name
When you’ve finished typing your additions in the Target text box, click OK. Now, when you start AutoCAD or AutoCAD LT, the drawing or template opens, and the script starts.
From within a script file, you can open (and close) other drawings. In this way, you can run a script file on as many drawings as you want. Figure 30-3 shows a script file, multi-cleanup. scr, that you could use when loading AutoCAD or AutoCAD LT. The target is set to Apt 1A.dwg.
Figure 30-3: A script file that cleans up three drawings.
Note Don’t forget that you can open multiple drawings within the same session of AutoCAD. You may need to set the SDI (single document interface) system variable to 1, if you plan to use older script files. Otherwise, use the CLOSE command to close each drawing after your script file has finished working on it. Without one of these methods, you may end up with 100 drawings open at once, and probably a major computer crash as well!
Chapter 30 Creating Macros and Slide Shows with Script Files |
969 |
Here’s how multi-cleanup.scr works:
1.The CHPROP command selects all objects and sets their color to BYLAYER.
2.The LAYER command freezes the layer named no-plot.
3.The script file saves the drawing.
4.The script file closes the drawing and opens the next drawing.
5.This process is repeated until the last drawing is edited and saved. The last drawing is left open.
Tip |
It’s nice to leave the last drawing open so that when you return to see the results, you can |
|
see that the last drawing has been properly edited. You then feel pretty sure that all of the |
|
previous drawings were similarly edited. |
Notice the quotation marks around the file names in the script file. These are necessary because the drawing file names include spaces.
In the following exercise, you practice creating and using a script file similar to the multicleanup script file used in the previous example, but for only one drawing.
On the |
The drawing used in the following exercise on creating and using a script file, ab30-a.dwg, |
CD-ROM |
is in the Drawings folder on the CD-ROM. |
STEPS: Creating and Using a Script File
1.Open ab30-a.dwg from the CD-ROM.
2.Save the file as ab30-01.dwg in your AutoCAD Bible folder.
3.In Windows, choose Start Run. Type notepad and click OK.
4.Type the following, replacing the underscores with spaces. Note that there should be two spaces between all and c. Press Enter after the qsave line.
chprop_all__c_bylayer -layer_f_no-plot qsave
5.Save the file as cleanup.scr in your AutoCAD Bible folder. Close Notepad. The script file changes the color property of all objects to ByLayer and freezes the no-plot layer. Notice that the drawing has some text that has been set to a blue color (maybe to make it more readable). The title block is on the no-plot layer.
6.Choose Tools Run Script.
7.In the Select Script File dialog box, find cleanup.scr in your AutoCAD Bible folder and click Open. The script runs, changing the text’s color to ByLayer (green) and freezing the no-plot layer. It also saves the drawing.
If the script file doesn’t work, press F2 to open the Text Window and see where the file got hung up. This will help you see where to correct the script file. Reopen it and make the correction. Save the file, close it, and try again.
8.Save your drawing.
