With the Customize Toolbars dialog box open, drag a button from one open toolbar to your new toolbar.. ✦ For commands that require inputting text such as layer or file names, enclosethe
Trang 1name of the file to edit, and Windows opens it in Notepad (You need to type in thecomplete path of the file.) To open Notepad without a file, press Enter at the *File
to edit:prompt
Creating keyboard shortcuts to commands
Most of the acad.pgpfile contains aliases, or keyboard shortcuts, for commonAutoCAD commands You can change these or add your own After you get used tothem, it’s often faster to type shortcuts at the command line than to click the tool-bar button or menu item, especially if your hands are already on the keyboard.You cannot include a command option in the acad.pgpfile To do that, you need
to create a menu item, toolbar button, or AutoLISP routine
The Express Tools contain an Alias Editor that enables you to edit the acad.pgpfile through a dialog box interface Choose Express ➪ Tools ➪ Command AliasEditor
The format for creating an alias is as follows:
Shortcut,*Full command nameRefer back to Figure 29-1 for some examples of shortcuts Note that the spacebetween the columns is not necessary — it simply improves readability
You can use aliases transparently if the command itself can be used transparently.Aliases cannot be used in script files or menus Note that you cannot use control orfunction keys in command aliases in the pgpfile
You can print out acad.pgp and tape it up on the wall where you work
If you are working on someone else’s computer, do not do the following Step exercise without that person’s permission It is not good computer etiquette
Step-by-to modify other people’s AuStep-by-toCAD files without asking first
Step-by-Step: Customizing the acad.pgp File
1 Start AutoCAD.
2 Place a blank disk in your floppy disk drive Type explorer↵ After opening apreliminary window, AutoCAD opens Windows Explorer using the acad.pgpshortcut
Caution Tip New
Feature
Trang 2By default, acad.pgp is in \Documents and Settings\[user name]\
Application Data\Autodesk\AutoCAD 2004\R16.0\enu\Support However,your location may be different, depending on your operating system and customiza-tion To find the location of acad.pgp, choose Tools ➪ Options and click the Files tab
Double-click the first item, Support File Search Path, to display the location of thesupport files
3 Find acad.pgp, click it, and drag it to the drive (in the Folders window) thatcontains your floppy disk Windows copies acad.pgpto the disk If youhaven’t already backed up your other customizable files, copy acad.lin,acad.lsp, acad.mln, acad.mnl, acad.mnu, and acad.patto the disk as well
(If they don’t fit, you may need to use two disks or a CD-ROM.) Remove thedisk and label it “AutoCAD customizable files — original form.”
4 While Explorer is open, double-click acad.pgp Windows opens the file in
Notepad (If Windows opens the Open With dialog box, choose Notepad fromthe list Check the Always Use This Program To Open This File option andclick OK From then on, Windows will automatically open your acad.pgpfilewith Notepad (Another method is to right-click and then choose Open With
to choose the application you want to use.)
5 Scroll down roughly two screens until you see the three Windows commands,
as shown in Figure 29-2 Place the cursor at the end of the PBRUSH line andpress Enter
Figure 29-2: The Windows commands
in the acad.pgpfile
6 Type the following and press Enter (the uppercasing and spaces are used to
match the format of the rest of the file):
WORDPAD, START WORDPAD, 1,,
7 Look at the next section of acad.pgp Read AutoCAD’s guidelines for creatingnew aliases
8 Scroll down until you see the following two lines:
CH, *PROPERTIES-CH, *CHANGEThe alias for the CHANGE command follows the guideline of using a hyphen todistinguish command-line versions of commands Suppose you have troublefinding that hyphen quickly (you end up typing =chinstead) You want tochange the alias to cg(with no hyphen)
Note
Trang 39 To be extra careful, add a new alias rather than changing the current alias
(which someone may be in the habit of using) Place the cursor after the word
*CHANGEand press Enter Type the following and press Enter (don’t worryabout the spaces — I’ve matched the spacing of the acad.pgpfile):
CG, *CHANGE
10 Choose File ➪ Save This section of acad.pgpthat you worked on should looklike Figure 29-3
Figure 29-3: A section of the edited acad.pgpfile
11 Close Notepad Generally, AutoCAD only reads acad.pgpwhen loading a new
or existing drawing However, you can use the REINIT command to reload the
file at any time Type reinit↵ AutoCAD opens the Re-initialization dialog box,
as shown in Figure 29-4
Figure 29-4: The Re-initialization dialog box
12 Check PGP File and click OK In your drawing, draw any line.
13 Type cg↵ AutoCAD starts the CHANGE command Select the line, right-click
to end selection, and pick a new endpoint location AutoCAD changes theendpoint of the line
14 Do not save your drawing.
The edited acad.pgp file is on the CD-ROM in the Results folder Although youmade only two changes, if you want, you can copy the acad.pgp file from theCD-ROM over your original acad.pgp file Of course, you can make additionalchanges to suit your needs
On the CD-ROM
Trang 4Customizing Toolbars
In the Windows environment, you frequently find yourself using toolbar buttons formany of your tasks Nevertheless, how many times have you found yourself typing
a command because you couldn’t quickly find an equivalent button on a toolbar,
or because it was on a flyout that was too annoying to deal with? In addition, thinkhow often you start a command with a toolbar button, only to return to the keyboard
to type in a simple option
You can customize AutoCAD’s toolbars to make your work easier and faster Youcan create new toolbars from scratch, or edit existing ones You can even createyour own toolbar buttons When you create a toolbar button, you can attach anysequence of commands to it — a complex macro or even an AutoLISP expression
Using the Customize dialog box
The Toolbars tab of the Customize dialog box (choose View ➪ Toolbars), shown inFigure 29-5, combines all the tools you need to manage toolbars
Figure 29-5: The Toolbars tab of the Customize
dialog box
To display a toolbar, you don’t need to use the Toolbars dialog box You can click any toolbar and choose from the list on the shortcut menu However, you canalso display toolbars from the Toolbars tab of the Customize dialog box by check-ing the toolbar you want to see Both lists include flyouts It is therefore very easy
right-to turn a flyout inright-to a right-toolbar if you want — click the flyout — for example, Zoom —and it appears as a regular toolbar
Trang 5You also use the Toolbars tab of the Customize dialog box to create new toolbars,delete toolbars, and customize existing toolbars If you create your own menus,they can have toolbars as well You can then choose toolbars from your menususing the Menu Group drop-down list.
Creating a new toolbar
To create a new toolbar, choose New in the Toolbars dialog box In the New Toolbardialog box, shown in Figure 29-6, name your toolbar (and the Menu Group if youhave created one) and then click OK Your toolbar now appears in the Toolbars list
of the Toolbars dialog box, and a small, new toolbar appears on the screen, asshown in Figure 29-7
You use menu groups when you start to create your own menus For more onMenu Groups, see Chapter 33, which covers customizing menus
Figure 29-6: The New Toolbar
dialog box
Figure 29-7: The new toolbar shown in the Toolbar list
and on the screen
Cross-Reference
Trang 6The new toolbar is just a baby, but as you add buttons to it, it grows automatically.
An important part of managing toolbars is finding a place to dock them so thatthey don’t take up valuable real estate on the screen You can make several smalltoolbars and fit them in the blank spaces next to existing toolbars The AutoCAD
2004 Standard toolbar is shorter than the previous one and gives you more roomfor your own toolbars
Removing buttons
You can customize any toolbar by removing buttons that you rarely use To removebuttons from a toolbar, follow these steps:
1 Display the toolbar.
2 Choose View ➪ Toolbars to display the Customize dialog box If necessary,
move it out of the way so you can access the toolbar that needs a buttonremoved
3 Drag the unwanted button off the toolbar and onto the screen area and
release the mouse button
It’s easy to forget that you need to have the Customize dialog box open to removebuttons because there’s no direct connection between dragging buttons off thetoolbar and the dialog box — but you can’t drag buttons off a toolbar unless thedialog box is open Inadvertently dragging a button off the Customize Toolbars dia-log box is also easy — if you do, you create a new toolbar
Adding buttons
If you have created a new toolbar, you need to add buttons to it You have severalways to do this:
✦ Add a button from the Commands tab of the Customize dialog box Display
the Commands tab of the Customize dialog box and choose a category
AutoCAD provides a number of preset buttons in each category (includingmany of the flyout buttons from Release 13) You can also choose AllCommands in the Category pane and then choose any command from thealphabetical Commands list Click a button to see its description at thebottom of the dialog box When you have found the button you want, drag
it to your new toolbar
✦ Move a button from another toolbar With the Customize Toolbars dialog box
open, drag a button from one open toolbar to your new toolbar This movesthe button, deleting it from the original toolbar
✦ Copy a button from another toolbar If you want to leave the original toolbar
intact, use the same technique as for moving a button, but hold down the Ctrlkey as you drag a button from one open toolbar to your new toolbar This pro-cedure copies the button
Note Tip
Trang 7Creating your own button definition
You can also create your own button definition from scratch Follow these steps:
1 With the Commands tab of the Customize dialog box displayed, choose User
Defined from the Categories list The Commands pane lists a User DefinedButton and User Defined Flyout
2 Drag the button you want onto your toolbar Because the buttons have no
borders, they are indistinguishable from the background until you click them
3 Click the Properties tab of the Customize dialog box and then click the blank
button to display the Button Properties tab of the Customize dialog box, asshown in Figure 29-8
Figure 29-8: The Button Properties tab of the
Customize dialog box
4 Type a name for the button This name appears as a tooltip, so don’t make it
too long
5 Type a help description in the Help text box This text appears on the status
line to further explain the function of the button
6 Write the macro AutoCAD places ^C^Cthere for you This cancels any othercommand that may be active when you use the button You can place anyvalid menu command string as it would be typed on the command line oreven an AutoLISP expression
You should use menu syntax for the macro I explain the details of creatingcommand strings in Chapter 33, where I cover customizing menus
Cross-Reference
Trang 87 Choose a button icon from the list of button icons or choose Edit to create
your own button, as explained in the next section
8 Click Apply and click the Close button of the Customize dialog box to close it.
Close any other open dialog boxes
AutoCAD updates the menus, showing its progress on the status bar
Using the Button Editor
The Button Editor, shown in Figure 29-9, enables you to make your own buttonicons Open the Button Editor by clicking Edit on the Button Properties tab of theCustomize dialog box You can choose one of the provided buttons and edit it —which I recommend — or start from scratch if you have artistic tendencies
Figure 29-9: The Button Editor
The center of the editing area shows an enlarged view of the button You see thebutton’s actual size at the top-left corner of the dialog box Check Grid to show agrid of pixels — this is just for your reference Choose a color from the color paletteand then choose one of the four tools at the top of the dialog box:
✦ The Pencil tool draws any shape To draw, drag it across the editing area
✦ Click and drag the Line tool to draw a straight line
✦ The Circle tool draws circles and ellipses You click the center and drag out
to the circumference to indicate the radius
✦ The Erase tool erases You can click to erase pixel by pixel or drag to erase aseries of pixels
Trang 9Here are the other features of the Button Editor:
✦ Choose Clear to clear the editing area and start from scratch
✦ Choose Open to open an existing button for editing Button icons are stored
as bmpfiles
✦ Choose Undo to undo your most recent action
✦ Choose Save to save the button icon as a bmpfile The default file name isICON.bmp
✦ Choose Save As to save an existing bmpfile under a new name
✦ Choose Close to close the Button Editor
✦ Choose More to select a standard index color or true color
With the introduction of true color support in AutoCAD 2004, you can now createyour toolbar icons with a wider variety of colors Choose More in the Button Editordialog box (shown in Figure 29-9) to access this colorful new feature
Creating flyouts
You can also create your own flyouts, or you can use one of the existing flyouts
To use an existing flyout, open the Commands tab of the Customize dialog boxand choose Flyouts You can simply drag one of these to a toolbar
To create your own flyout, follow these steps:
1 Create a toolbar with the buttons that you want on the flyout, as explained in
the previous section
2 Open the Customize dialog box and display the Commands tab.
3 Choose User Defined from the Categories list and drag User Defined Flyout
from the Commands list onto an existing toolbar You see a blank flyout on thetoolbar
4 Click the Properties tab of the Customize dialog box and then click the blank
flyout button to display the Flyout Properties tab, shown in Figure 29-10
4 You see a message telling you to associate a toolbar with the flyout.
5 From the list of toolbars, choose the new toolbar that you created This
tool-bar will be the flyout from the flyout button you just added
6 Click Apply and then click Close.
7 Your new toolbar is now a flyout on a toolbar You can close the new toolbar
you created because you can access it from its parent toolbar
New
Feature
Trang 10Figure 29-10: The Flyout Properties tab of the
Customize dialog box
The following exercise changes your menu files After the exercise, I explain how toundo the changes if you want If you are working on someone else’s computer, do not
do this exercise without that person’s permission As I mentioned before, it is notgood computer etiquette to modify other people’s AutoCAD files without asking first
Step-by-Step: Customizing Toolbars
1 Open Windows Explorer and copy acad.mnu, acad.mnc, and acad.mnsfromthe AutoCAD 2004\Supportfolder to a floppy disk Label and date the disk
By default, acad.mnu, acad.mnc, and acad.mns are in \Documents and
Settings\[user name]\Application Data\Autodesk\AutoCAD 2004\
R16.0\enu\Support However, your location may be different, depending onyour operating system and customization To find the location of acad.mnu,acad.mnc, and acad.mns, choose Tools ➪ Options and click the Files tab
Double-click the first item, Support File Search Path, to display the location of thesupport files
2 Start a new drawing using any template Save the file as ab29-01.dwgin yourAutoCAD Biblefolder
3 Choose View ➪ Toolbars to open the Customize dialog box From the Toolbars
list, scroll down to find the Zoom toolbar and check it When it appears, drag
it away from the Toolbars dialog box, if necessary
4 Drag the Zoom Center and Zoom All buttons off the toolbar (or choose the
two buttons that you use least and drag them off), confirming the deletioneach time A small space appears between the last (Zoom Extents) button andthe rest of the buttons Drag the Zoom Extents button to the left slightly toeliminate the space
Note
Trang 115 Drag the toolbar to the space at the right of the Standard toolbar and dock it
there (The space you have depends on the size of your screen and yourscreen resolution If it doesn’t fit, drag one more button off the toolbar ordock it on the right side of the screen.)
6 Choose New on the Toolbars tab In the New Toolbar dialog box, type Special
in the Toolbar Name text box and click OK A small toolbar appears on yourscreen
7 Click the Commands tab From the Categories list, choose Draw Find the
Donut button and drag it to your new toolbar The I-beam cursor on thetoolbar indicates the button placement
8 Choose the Modify category and find Edit Polyline Drag it to your new
toolbar
9 Choose the View category and drag Hidden to the toolbar.
10 Choose the User Defined category and drag User Defined Button to the new
toolbar Click the blank button to display the Button Properties tab
11 Complete the dialog box, as shown in Figure 29-11 Type the macro as follows
after the ^C^C,which is already there, being careful to include the spaces
as well:
pedit \w 1 ;
12 Choose the Polyline Edit button from the Button Icon list, as shown in Figure
29-11 Choose Edit to open the Button Editor
Figure 29-11: The completed Button Properties
dialog box
Trang 1213 You want to change the button so that it looks as if a zero-width polyline is
being changed to a wider polyline because that’s what the macro does Clickthe red color Choose the pencil tool (by default, it is already chosen) ClickGrid to help you work Click (or drag) the point of the pencil tool in each box,using Figure 29-12 as a guide (Figure 29-12 shows the button in black andwhite.) When you’re done, choose Save and then Close
Figure 29-12: The new button
If you make a mistake, it’s easy to correct it If you place a red pixel over an ing black pixel, choose black and redraw the black pixel If you place a red pixel in
exist-a wrong spot, choose the Erexist-ase tool exist-and click the pixel
14 On the Button Properties tab, click Apply The new button appears in your
toolbar Click the Close button to close the dialog box AutoCAD saves thechanges to your menu source file (.mns).
15 Drag the new toolbar under the Zoom toolbar you modified (If it doesn’t fit,
dock it on the right side of the screen.)
16 Choose Polyline from the Draw toolbar and draw any series of polyline
segments Choose the Plines 1 wide button from the new toolbar At theSelect polyline:prompt, pick the polyline AutoCAD changes its width to0.1 (If it doesn’t work, check the macro Right-click the Plines 1 wide button,choose Customize, and click the Plines 1 wide button to open the ButtonProperties tab.)
17 Save your drawing.
If you later customize the ACAD menu by editing acad.mnu, your toolbar cations will be erased! In Chapter 33, where I discuss customizing AutoCAD’smenus, I explain how to avoid this problem
modifi-Caution Tip
Trang 13Undoing toolbar changes
To undo your toolbar changes, you need to reload the template menu, acad.mnu Thisoverwrites the compiled and source menu files that include your toolbar changes The fol-lowing steps explain the process But first, be sure to have a backup of your acad.mnu,acad.mnc, and acad.mns files (To find the location of the menu files, choose Tools ➪Options and click the Files tab Double-click the first item, Support File Search Path, to dis-play the location of the support files.)
1.Choose Tools ➪ Customize ➪ Menus The Menu Groups tab should be on top In theMenu Groups box, ACAD should be highlighted, as shown here
2.In the bottom section of the dialog box, check Replace All so that AutoCAD loads all
your menu files on the menu bar In the File Name box, type acad.mnu and click
Load When you load the acad.mnufile, AutoCAD warns you that you will lose anytoolbar customization changes you have made, as shown in the following figure.Click Yes because you do want to overwrite all your toolbar customization changes
3.AutoCAD loads the menu and displays the message Menu loaded successfully.MENUGROUP: ACAD Click Close Your new toolbars and buttons disappear
Reloading acad.mnuwould remove any partial menus that you may have loaded For moreinformation, see my coverage of menu files in more detail in Chapter 33
Trang 14Here’s how the peditmacro you used in the previous Step-by-Step exercise works:
pedit \w 1 ;
1.Peditissues the PEDIT command The space after peditis equivalent topressing Enter after you have typed the command on the command line
PEDIT then displays the Select polyline:prompt
2 The backslash (\) is a special character that pauses the macro for your input.
When you select the polyline, the macro continues, displaying the Enter anoption [Close/Join/Width/Edit vertex/Fit/Spline/Decurve/Ltypegen/Undo]:prompt
3 The wthen specifies the Width option The space following it is like pressingEnter PEDIT 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.
PEDIT then issues the Enter an option [Close/Join/Width/Editvertex/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 and hatches I cover tool palettes inChapter 26 Some customization can be accomplished on the tool palettes them-selves Here I explain the procedure for customizing the tool palettes using theCustomize dialog box
To customize tool palettes, choose Tools ➪ Customize ➪ Tool Palettes to display theTool Palettes tab of the Customize dialog box, shown in Figure 29-13 The currenttool palettes are listed Remember that each tab on the Tool Palette window is con-sidered a separate tool palette
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 click Up or Down This action moves the tab up or down oneand also changes the tab’s order in the dialog box listing Continue to click Up
or Down until the tab is in the desired position You can also move the tabsdirectly on the Tool Palette by right-clicking the tab name and choosing Move
Up or Move Down
✦ Create a new tool palette: Click New In the New Tool Palette dialog box, enter
a name and click OK To create a new tool palette on the palette itself, click anywhere on the palette and choose Create New Tool Palette
Trang 15right-✦ Rename a tool palette: Click Rename In the Rename Tool Palette dialog box,
enter a new name and click OK To rename a tool palette on the palette itself,right-click on the tab’s name and choose Rename Tool Palette
✦ Delete a tool palette: Click Delete In the Confirm Tool Palette Deletion dialog
box, which warns you that deletion is permanent unless you first export thetool palette, click OK to delete the tool palette You can also right-click anytool palette and choose Delete Tool Palette
✦ Import a tool palette: Click Import In the Import Tool Palette dialog box,
locate the xtpfile and click Open
✦ Export a tool palette: Click Export In the Export Tool Palette dialog box,
choose the location for the file You can change the name if you want The toolpalette is saved as an xtpfile Click Save
Figure 29-13: The Tool Palettes
tab of the Customize dialog box
Summary
In this chapter, I covered the basics of customizing AutoCAD You started to tomize AutoCAD by:
cus-✦ Creating command shortcuts (aliases) in the acad.pgpfile
✦ Creating your own toolbars that can contain any command sequence youneed
✦ Working with tool palettes, a new feature of AutoCAD 2004, including changingtheir order, renaming and deleting them, and also saving them as a file so thatyou can share them with others
In the next, chapter you read how to create macros with script files
Trang 16Creating Macros and Slide Shows with Script Files
Script files are like macros that you create in your word
processor or spreadsheet They execute a series of mands automatically You can use script files to automateplotting, set up a drawing, clean up a drawing, create a slideshow, or do any repetitive task
com-Creating Macros with Script Files
To create a script file, you need to think out the commandsthat you want to execute and their options and prompts Thenyou create the text for the script file Script files have the fol-lowing characteristics:
✦ They must use the scrfile name extension
✦ They are text-only (ASCII) files
✦ They must use command-line syntax only
One of the most common uses for script files beforeRelease 14 was to automate plotting of several drawings atonce The Batch Plot Utility, introduced with Release 14,can do many multiple plotting tasks for you
Creating the script file
You can create the script file using a text editor, such asNotepad For early practice with script files, type each com-mand on its own line A blank space is equivalent to pressingEnter End each line by pressing Enter (also called Return),without extra blank spaces If you need two returns one afteranother at the end of a line, use a blank line for the second
Trang 17return Every space is meaningful — getting those spaces and blank lines right isprobably the hardest part of creating a script file One technique is to start yourscript files in a word processing program that can display with nonprinting charac-ters (blank spaces and returns) You can either save the script file in text format orcopy it into Notepad Following are some tips to help you create successful scriptfiles with the least aggravation:
✦ Go through the steps once using the command line only before creating thescript file
✦ If you will use any dialog boxes that ask for files, set the system variable DIA to zero (off) before experimenting with the commands you will use in thescript file This lets you practice the keystrokes without opening dialog boxes
FILE-Or you can practice using the version of the command with the hyphen infront of it (such as -layer); in most cases, you don’t need the hyphen in thescript file itself
AutoCAD automatically runs script files as if FILEDIA were off, even if it is set to 1 (on)
✦ For commands that require inputting text such as layer or file names, enclosethe names in quotation marks and for the next use of Enter, press Enter and
go to the next line in the script instead of using a space Otherwise, AutoCADmay misinterpret a space as a space in the layer or file name, rather than anEnter
✦ Place comments in your script file to explain what you are doing A comment
is any line that starts with a semicolon
✦ Keep Notepad open as you work When you have completed a set ofkeystrokes that you want, open the AutoCAD Text Window (press F2), selectthe command string you want, right-click, choose Copy, switch back toNotepad, and paste Then cut out all the prompts, leaving only the keyboardentry You will probably have to readjust the spaces between the words
✦ You can press End to check for blank spaces at the end of a line PressingCtrl+End moves the cursor to the end of the document — useful for checkingfor 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 Theacad.pgpfile includes this Windows command by default See Chapter 29 fordetails on the acad.pgpfile
Another option is to simply write down what you type at the command line As youwrite, use an underscore to represent each space It’s very hard to remember thatyou left three spaces between two words unless you see three underscores Ofcourse, when you create the script file, you must use spaces, not underscores
Note
Trang 18As soon as you complete the script file, save it with any name that is meaningful toyou plus an extension of scr.
Here’s an example of a script file that draws a series of circles:
circle 2,2 1.5circle 6,2 1.5circle 10,2 1.5circle 14,2 1.5This script file starts the CIRCLE command, specifies a center point, and specifies aradius four times The results are shown in Figure 30-1
Figure 30-1: Running a script file created this drawing
Running script files
You can run a script file from within a drawing Use this technique when you wantthe script to apply only to that drawing However, you can also start a script within adrawing, then close the drawing and continue on to open and process other drawings
You can also run a script file when loading AutoCAD You would do this when youwant the script file to apply to more than one drawing For example, you could usescript files in the following situations:
✦ You want to use a script file to set up every drawing you open Although thescript file applies to only one drawing at a time, you use it on a different draw-ing 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 the drawings in a folder
Running a script file from within a 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, as
shown in Figure 30-2
Trang 19Figure 30-2: The Select Script File dialog box
2 Choose the script file you want.
3 Click Open AutoCAD runs the script file.
Running a script when loading AutoCAD
Run a script when loading AutoCAD by changing the target expression thatWindows uses to open AutoCAD The easiest way to do this is to use the shortcut
to AutoCAD on your desktop and modify the target there Right-click the AutoCADshortcut and choose Properties Click the Shortcut tab, shown in Figure 30-3
Figure 30-3: The Shortcut tab of the
AutoCAD 2004 Properties dialog box
Trang 20The Target text box displays the command expression that Windows uses to openAutoCAD Don’t make any change to the current expression — just add to it Theformat for starting a script file is:
drive:\path\acad.exe drive:\path\drawingname.dwg /b script_fileFor example, if your current target readsC:\Program Files\AutoCAD
2004\acad.exeand you want to open a drawing named ba-349.dwgin ingsand run a script file named pre-plot.scr, your target should read:
c:\draw-“C:\Program Files\AutoCAD 2004\acad.exe” c:\drawings\ba-349.dwg/b pre-plot
You don’t need to add the scrextension after the script file name Long file namesthat contain spaces must be enclosed in quotation marks — both in the target and inthe script file itself You need to include the full path of the drawing If the script file
is not in AutoCAD’s support file search path, include the entire path For example:
“C:\Program Files\AutoCAD 2004\acad.exe” “c:\aec\drc\DobbsFerry Apts.dwg” /b c:\aec\drc\cleanup
If you want to start a new drawing, you might want to specify a template In the ceding format, replace the AutoCAD drawing file name with:
pre-/t template_nameWhen you have finished typing your additions in the Target text box, click OK Now,when you start AutoCAD, the drawing or template opens, and the script starts
From within a script file, you can open (and close) other drawings In this way youcan run a script file on as many drawings as you want Figure 30-4 shows a scriptfile, multi-cleanup.scr, which is used when loading AutoCAD The target is set
so that AutoCAD opens Apt 1A.dwg
Figure 30-4: A script file that cleans
up three drawings
Trang 21Don’t forget that you can open multiple drawings within the same session ofAutoCAD You may need to set the SDI (single document interface) system vari-able to 1, if you plan to use older script files Otherwise, use the new CLOSE com-mand 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 atonce — and probably a major computer crash as well!
Here’s how multi-cleanup.scrworks:
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
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 prettysure that all the previous drawings were similarly edited
Notice the quotation marks around the file names in the script file These are sary because the drawing file names include spaces
neces-In the following exercise you practice creating and using a script file similar to themulti-cleanup script file used in the previous example, but for only one drawing
The drawing used in the following Step-by-Step exercise on creating and using a
script file, ab30-a.dwg, is in the Drawings folder of the AutoCAD 2004 Bible
CD-ROM
Step-by-Step: Creating and Using a Script File
1 Open ab30-a.dwgfrom the CD-ROM
2 Save the file as ab30-01.dwgin your AutoCAD Biblefolder
3 Type notepad↵ At the File to edit:prompt, press Enter to open a newfile
4 Type the following, replacing the underscores with spaces Note that there
should be two spaces between alland cin the second line Press Enter afterthe qsaveline
chprop_all c_bylayer-layer_f_no-plotqsave
5 Save the file as cleanup.scrin your AutoCAD Biblefolder Close Notepad
On the CD-ROM Tip Note
Trang 22The script file changes the color property of all objects to ByLayer andfreezes the no-plot layer Notice that the drawing has some text that has beenset to a blue color (maybe to make it more readable) The title block is on theno-plot layer.
6 Choose Tools ➪ Run Script.
7 In the Select Script File dialog box, find cleanup.scrin your AutoCAD Biblefolder and click Open AutoCAD runs the script, changing the text’s color toByLayer (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 seewhere it got hung up This will help you see where to correct the script file
Reopen it (on the Windows task bar choose Start ➪ Documents or Start ➪
My Recent Documents (depending on your version of Windows) and choosecleanup.scr) and make the correction Save the file, close it, and try again
8 Save your drawing.
Taking script files to the max
What if you want to execute that multi-cleanup script file on 200 drawings? Typing in allthose file names would take so long you would wonder if you were saving any time
You can save time First, you need to find a text editor or word processor that can create
ver-tical blocks of text This means that you can select columns of text rather than lines of text
You can do this in Microsoft Word by holding down Alt and dragging down the text (Using afixed-width font, such as “Courier New” makes selecting columns of text easier.) Then, youneed to format the script file so that the entire set of commands is in one row, as in the figureshown here In Microsoft Word, you can use Page Setup to set the paper to landscape andmake it as wide as you need so that the text doesn’t wrap (Of course, you type the scriptonce, and then copy the line and paste it as many times as you need.) You do this so that allthe file names will be in one column Here you see the path but no file name at the end ofeach line The file name will be inserted before the quotation mark at the end of each line
Now, open a DOS window (From the Windows task bar, choose Start ➪ ProgramsAccessories ➪Command Prompt.) Use the DOS cdcommand to navigate to the folder where all your draw-
ings are (They should all be in one folder.) Type dir *.dwg /b >dwglst.txt and press Enter.
This creates a listing of all the files in that folder and places it in a text file named dwglst.txt.The /bparameter creates a file that contains only the names of the drawings
Open the file in a text editor or word processor that can create vertical blocks Create a tical block over the drawing names and copy it to the clipboard
ver-Continued
Trang 23Creating Slide Shows
One common use for script files is to create a slide show AutoCAD enables you tosave a view of a drawing as a slide You can then create a slide library from theslides and show the slides one after another automatically
You can save any drawing as an image file and import it into a presentation gram that creates slide shows, such as Microsoft PowerPoint, Lotus FreelanceGraphics, or Corel Presentations You can add text, special effects, and more to cre-ate a professional slide show For more information, see “Saving rendered images”
pro-in Chapter 25 and “Exportpro-ing to other file formats” pro-in Chapter 27
Creating slides
Creating a slide is like capturing the screen of your drawing AutoCAD makes a plified vector file from the current viewport in model space, or from all viewports in
sim-paper space layouts You can also create a slide of a wireframe, or hidden display.
Unfortunately, you cannot make slides of shaded or rendered displays
To create a slide, follow these steps:
1 Display the view of the drawing that you want to save as a slide.
2 Type mslide↵
3 In the Create Slide File dialog box, choose a location and name for the slide.
Its extension will automatically be sld
top-to save the file as a Text Only document
Used in this way, script files can be an extremely powerful tool for editing large numbers ofdrawings in one batch
Trang 24Viewing slides
To view a slide, follow these steps:
1 Type vslide↵
2 In the Select Slide File dialog box, choose the slide you want to view.
3 Choose Open AutoCAD displays the slide.
Do a Redraw to return to your drawing You cannot draw in or edit a slide
The drawing used in the following Step-by-Step exercise on creating and using a
script file, ab30-b.dwg, is in the Drawings folder of the AutoCAD 2004 Bible
CD-ROM
Step-by-Step: Creating and Viewing Slides
1 Open ab30-b.dwgfrom the CD-ROM
2 Save the file as ab30-02.dwgin your AutoCAD Biblefolder
3 Type hide↵ AutoCAD hides the drawing
4 Type mslide↵ In the Create Slide File dialog box, click the Save in drop-downbox and select your AutoCAD Biblefolder, if it isn’t already selected In theFile name text box, change the name from its default of ab30-02.sldtoab30-02a.sld Click Save
5 Choose View ➪ 3D Orbit from the Standard toolbar Click and drag the right
quadrant circle of the arcball slightly to the left Press Esc
6 Issue the MSLIDE command again This time save the slide as ab30-02b.sld
7 Choose 3D Orbit from the Standard toolbar Again, click and drag the right
quadrant circle of the arcball slightly to the left Press Esc
8 Issue the MSLIDE command again and save the slide as ab30-02c.sld
9 Click Zoom Previous on the Standard toolbar until you see the message Noprevious view saved
10 Type vslide↵ In the Select Slide File dialog box, choose the first slide,ab30-02a.sld Click Open AutoCAD displays the slide
11 Repeat the VSLIDE command and display ab30-2b.sld Do the same withab30-02c.sld
12 Click Redraw All on the Standard toolbar.
13 Save your drawing.
On the CD-ROM
Trang 25Using scripts to create slide shows
You can create a script file that displays slides one after another, resulting in a slideshow AutoCAD provides two special script file commands for this purpose:
✦ DELAY nnnn pauses the script for the number of milliseconds you specify For
example, DELAY 3000 pauses the script for three seconds
✦ RSCRIPT repeats the script from the beginning Use this command to create acontinuously running script To stop the script (whether repeating or not),press Esc or backspace, or drop down any menu
✦ RESUME restarts a script file after you have stopped it
The VSLIDE command, which displays a slide, can also be used to preload the nextslide into memory You use this command to preload a slide while viewers are look-ing at the previous slide This reduces the waiting time between slides To use thisfeature, put an asterisk (*) before the file name in the VSLIDE command The nextVSLIDE command detects that a slide has been preloaded and displays it withoutasking for the slide name Here’s how it works:
vslide ab30-2avslide *ab30-2bdelay 3000vslidevslide *ab30-2cdelay 3000vsliderscriptThis script file does the following:
8 It repeats the script from the beginning.
Step-by-Step: Creating a Slide Show
1 Open Notepad and type the following script:
vslide ab30-02avslide *ab30-02bdelay 3000
Trang 26vslidevslide *ab30-02cdelay 3000vslidedelay 3000rscript
2 Remember to press Enter at the end of the last line Save the file as
ab30-02.scrin your AutoCAD Biblefolder Close Notepad
3 So that AutoCAD can find the slide files, place your AutoCAD Biblefolder inAutoCAD’s support file search path To do this, click Tools ➪ Options ➪ Filestab Click Support File Search Path and click Add Click Browse and find yourAutoCAD Biblefolder Click OK twice
4 In any AutoCAD drawing, choose Tools ➪ Run Script Locate ab30-02.scrinyour AutoCAD Biblefolder and click Open AutoCAD runs the slide show
Notice that the last slide still takes a while to display
5 Let the slide show run through twice The last slide displays a little more
quickly the second time Press Esc to stop the slide show
6 Do not save your drawing.
When running a slide show, you might want to maximize the screen area by ing menu and command-line space You can unload your menu, thus quickly dis-missing toolbars from the screen Use Tools ➪ Options ➪ Display to reduce thenumber of lines of text to show on the command line to 1 Remember that whenyou unload the menu, you have no menus available You can reload the menu byfollowing the instructions for unloading and loading menus in Chapter 33
reduc-Creating Slide Libraries
You can organize your slides into slide libraries Slide libraries have an extension of.slb One reason for creating slide libraries is to create image tiles when you arecustomizing your menu To see an example of an image tile menu, choose Draw ➪Surfaces ➪ 3D Surfaces These image tiles are created with slides organized intolibraries
To view slides in a library, use the following format:
library(slidename)Say that you placed the three slides used in the preceding Step-by-Step exercise in aslide library called 3dmodel.slb You would then use the following command inthe script file to preload the second slide (the second line of the script file):
vslide *3dmodel(ab30-02b)
Tip
Trang 27To create a slide library, you need to use the DOS prompt AutoCAD provides theSLIDELIB utility in its AutoCAD 2004 folder to create slide libraries.
To get to the DOS prompt, choose Start ➪ Programs ➪ Accessories ➪ CommandPrompt
Follow these steps to create a slide library:
1 Create a text file (you can use Notepad) containing the names of the slide
files Include the paths of the slide files if they are not in AutoCAD’s supportfile search path Place each slide file name on a new line
SLIDELIB can read a listing created using DOS’s dir command with the /b eter, which creates a simple listing of just the file names Therefore, you can placeall the slide files in a folder and redirect the dir listing to a file For example, youcan create a list named ab30sld.lst by typing the following at the DOS prompt:dir *.sld /b >ab30sld.lst
param-This creates the list in the same folder as the slide files
2 Assuming that you are still in the same folder where you created the slide file
list and you want to create a library called ab30sld.slbin the same folder,type the following at the DOS prompt:
“c:\program files\acad2004\slidelib” ab30sld < ab30sld.lstSLIDELIB cannot accept file names with spaces but it can handle long file names,provided you use a character, such as an underscore where you might normallyhave a blank space
command-✦ Running script files from within a drawing or when loading AutoCAD
✦ Creating slides from the display in your viewport and creating a script file thatdisplays several slides one after another, resulting in a slide show
✦ Organizing your slides into slide libraries
In the next chapter, you read how to create your own linetypes and hatch patterns
Note Tip
Trang 28Creating Your Own Linetypes and Hatch
Patterns
As you know, AutoCAD comes with a large number of
linetypes However, sometimes these may not serveyour particular needs You can therefore create your ownlinetypes and use them in your drawings in the same way youuse the linetypes that AutoCAD provides Linetypes are usefulwhenever you don’t want a continuous linetype They applynot only to lines, but also to polylines, arcs, ellipses, wire-frames, and solids — in fact, to most AutoCAD objects
Creating Linetypes
There are two types of linetypes: simple and complex Simplelinetypes consist of dashes and dots only Complex linetypesusually have dashes and/or dots also but contain text and/orshapes as well
The default linetype file is acad.lin You can add your ownlinetype definitions to this file or create your own linetypefiles Linetype files are text files and must have an extension of.lin Of course, be sure to make a backup copy of acad.linbefore you edit it
Creating simple linetypes
In the syntax for creating simple linetypes, each linetype isdefined using two lines of text The first line contains the line-type name and an optional description, formatted as follows:
*linetype name[, description]
31C H A P T E R
In This Chapter
Creating linetypesCreating hatchpatterns
Trang 29Here are the points to note:
✦ Always start the definition with an asterisk
✦ The description is limited to 47 characters
✦ If you include a description, precede it with a comma
The second line of the linetype syntax is its definition With simple linetypes, youare limited to dashes, dots, and spaces, measured in units and shown as follows:
✦ A dash is indicated by a positive number
✦ A dot is indicated by a zero
✦ A space is indicated by a negative number
✦ Each item is separated by a comma, there are no spaces, and the maximumline length is 80 characters
✦ Each line must start with the letter A
The following definition creates a line with two dashes of 0.25 units, followed bytwo dots, all separated by spaces of 0.1 units
*seeingdouble, Future hedge lineA,.25,–.1,.25,–.1,0,–.1,0,–.1The result is shown in Figure 31-1
Figure 31-1: The seeingdouble linetype
If you feel quite confident, you can even create linetypes on the fly, using the
command-line form of the LINETYPE command Type -linetype↵and use the Createoption Follow the prompts and type the linetype definition on the command line
If you make a mistake, you still have to open the linetype file in a text editor tomake corrections
If your linetype definition will include both dashes and dots, you’ll get best results
if you start a linetype definition with the dash Starting the definition with a dash is
a matter of aesthetics, perhaps, but such a line connects better to other lines
Step-by-Step: Creating a Simple Linetype
1 Open a drawing using the acad.dwttemplate
2 Save your drawing as ab31-01.dwgin your AutoCAD Biblefolder
3 Type notepad and press Enter at the File to edit:prompt to open a newfile in Notepad
Tip
Trang 304 Type the following:
*3dotsandadash, temporary fencingA,.5,–.25,0,–.1,0,–.1,0,–.25
5 Press Enter after the last line Save the file as ab31-01.linin your AutoCADBiblefolder and close Notepad
6 In your drawing, choose Layer Properties Manager on the Layers toolbar and
then click New Name the new layer tfence Set its color to red
7 Click Continuous in the Linetype column to open the Select Linetype dialog
box Click Load
8 In the Load or Reload Linetypes dialog box, click File In the Select Linetype
File dialog box, find ab31-01.linin your AutoCAD Biblefolder, choose it,and click Open
9 Back in the Load or Reload Linetypes dialog box, choose 3dotsandadash and
click OK
10 Again, in the Select Linetype dialog box, choose 3dotsandadash and click OK.
The layer tfence now shows the correct linetype Click Current and then OK
11 Start the LINE command and turn on ORTHO Draw any line to see the
line-type Save your drawing The linetype should look like Figure 31-2
Figure 31-2: The 3dotsandadash linetype
Creating complex linetypes
A complex linetype includes either shapes or text in the linetype definition Figure31-3 shows an example of each
Complex linetype definitions are similar to those for simple linetypes, except thatthey add a definition for a shape or text
Figure 31-3: Complex linetypes include shapes or text.
Trang 31Shapes are covered in the next chapter — for now you only need to know that theyare contained in files with the extension shx.
The first line of the linetype definition is the same as for simple linetypes The ond line of the definition can contain all the same features as those for a simplelinetype However, you add the special shape or text definition in square brackets:
sec-✦ Syntax for shapes:[shapename,shxfilename,details]
✦ Syntax for text:[“text string”,textstyle,details]
“Details” refers to an optional series of rotation, scale, and offset specifications thatyou can add to the definition Table 31-1 describes these specifications
The following complex linetype definition uses a shape and has no details:
*TEMPFENCE, FENCE SHAPE AND DASHA,.5,–.25,[FENCE,”C:\AUTOCAD BIBLE\FENCE.SHX”],–.5Note that the specification for the shape is simply part of the rest of the definitionthat includes a dash and spaces before and after the shape The shape is enclosed
in both commas and square brackets The first part of the shape definition is thename of the shape (which is defined in the shape’s definition file), and the secondpart is the name of the shape file In this case the shape file is not in AutoCAD’s sup-port file search path so the entire path needs to be specified Don’t forget to usequotation marks around the shape file name if the folder name or file name containsembedded spaces
Note that the space after the shape (created with the –.5 code) is larger than thespace before it (created with the –.25) You need to allow for the space that theshape takes up This is largely a matter of trial and error, but if you know the shapedefinition well, you can make a good estimate When you go back and change thelinetype definition (if your first trial was an error), don’t forget to reload the line-type (by using the Load option)
The following complex linetype definition uses text and has no details:
*TFENCE, DASH & TEXTA,.5,–.25,[“TEMP FENCE”,FENCE],–1.5Again, the specification for the text is placed within a linetype definition thatincludes a dash and spaces The first part of the text definition is the text string,which is always in quotation marks The second part of the definition is the textstyle Again, the space after the text is larger than the space before, to leave roomfor the text
You must define the text style in the drawing before you load the linetype
Table 31-1 lists the details that you can add to both the shape and text portion ofcomplex linetype definitions
Tip
Trang 32Table 31-1
Optional Details for Shapes and Text in Complex Linetype Definitions
Detail Syntax Description
Relative rotation R=## Rotates the shape or text relative to the angle of the line you
draw This number is in degrees unless you put a g (for grads) or r (for radians) after it.
Absolute rotation A=## Rotates the shape or text based on the World Coordinate
System, regardless of the angle of the line Because the default is a relative rotation of zero, you can use absolute rotation to keep text facing upright, no matter what the direction of the line This number is in degrees unless you put a g (for grads) or r (for radians) after it.
Scale S=## Scales the text or shape This scale is multiplied by any scale
contained in a shape definition or height in a text style If you use a text style with a height of zero, this scale number defines the text’s height.
X offset X=## A positive number moves the shape or text toward the
endpoint of the line A negative number moves the shape or text toward the start point of the line You can use an X offset to place a shape or text along a continuous linetype.
You can also use an X offset to adjust the spacing of a shape
or text between dashes, instead of changing the spaces before or after the dashes.
Y offset Y=## Moves the shape or text perpendicular to the direction of the
line A positive number moves the shape or text up if the line is drawn from left to right Use a Y offset to center text and shapes along a linetype.
*Although using an absolute rotation of zero might sound like a good idea for complex linetypes with text, if you use the linetype at varying angles or on curves, you may find that the text shifts to an undesirable location due
to the text’s justification point.
Here is a definition that includes a shape with a scale and a Y offset:
*TEMPFENCE, FENCE SHAPE AND DASHA,.5,–.25,[FENCE,”C:\AUTOCAD BIBLE\FENCE.SHX”,S=.025,Y=-.07],–.5This shape definition scales the shape to 0.025 of its original size This results in thelinetype shown in Figure 31-4 Of course, in order to scale the shape, you need toknow its original size You can use the SHAPE command to insert a shape and get anidea of what it looks like In this case, the shape’s original definition is much toolarge for a linetype and needs to be scaled down
Trang 33Figure 31-4: The TEMPFENCE linetype
The shape definition also moves the shape in the minus Y direction by 0.07 units.This nicely centers the shape within the linetype
When you create drawings by using shapes or custom fonts, as in the case of plex linetypes, you need to include the shape files or font files when you distributethe drawings to others
com-By including more involved shapes in a complex linetype and not much else, youcan create a linetype that is, for all practical purposes, a series of shapes displayedone after the other You can create some interesting effects in this way
AutoCAD comes with several complex linetypes that are at the end of the \support\acad.linlinetype definition file Look at their definitions and try them out to getideas for your own complex linetypes Express Tools have a command, MKLTYPE(choose Express ➪ Tools ➪ Make Linetype) that automatically creates linetypes, evencomplex ones
By default, acad.lin is in \Documents and Settings\[user name]\Application Data\Autodesk\AutoCAD 2004\R16.0\enu\Support However,your location may be different, depending on your operating system and customiza-tion To find the location of acad.lin, choose Tools ➪ Options and click the Files tab.Double-click the first item, Support File Search Path, to display the location of thesupport files
The drawing used in the following Step-by-Step exercise on creating a complex
linetype, ab31-a.dwg, is in the Drawings folder of the AutoCAD 2004 Bible
CD-ROM
Step-by-Step: Creating a Complex Linetype
1 Open ab31-a.dwgfrom the CD-ROM
2 Save the file as ab31-02.dwgin your AutoCAD Biblefolder This drawing is asimple plan for a trailer park
3 Choose Format ➪ Text Style Click New and type TVCABLE for the Style name.
Click OK In the Font name drop-down list, choose Arial Click Apply and thenClose
4 Type notepad↵and press Enter at the File to edit:prompt AutoCADopens Notepad Type the following:
*TV, Buried television cableA,.5,-.5,[“TV”,TVCABLE,S=.3,X=-.1,Y=-.15],-.75
5 Choose File ➪ Save and save it in your AutoCAD Biblefolder asab31-02.lin
On the CD-ROM Note Caution
Trang 346 Choose Layer Properties Manager from the Layers toolbar Choose
Buried_cableand click its Continuous linetype in the Linetype column
In the Select Linetype dialog box, choose Load Click File Find ab31-02.lin
in your AutoCAD Biblefolder, choose it, and click Open
7 In the Load or Reload Linetypes dialog box, choose TV and click OK Do the
same in the Select Linetypes dialog box Click Current Click OK
8 Click Linetype Control from the Layers toolbar and choose Other In the
Linetype Manager, click Show Details to display the Details section Changethe Global Scale Factor to 192 Click OK
9 Draw some lines or polylines Zoom in to see the linetype more clearly.
Figure 31-5 shows the resulting linetype
10 Save your drawing.
Figure 31-5: The TV linetype
Creating Hatch Patterns
Hatch patterns are sets of parallel line patterns that are used to fill an enclosed area
Although the part of the hatch pattern definition that defines each line has some larities to a linetype definition, for hatch patterns you also need to specify the angleand spacing of the lines You cannot include text or shapes in hatch patterns
simi-Hatch patterns are stored in files with an extension of pat AutoCAD includes alarge number of hatch patterns in acad.pat You can add to or edit this file orcreate your own patfile As always, don’t forget to make a copy of acad.patbefore you edit it When creating your own patfile, remember the following:
✦ If you are not adding patterns to acad.pat, you can only put one hatch tern in a custom patfile The file name and pattern name must be the same
pat-✦ You can insert comments in your patfile after a semicolon
✦ You must press Enter after the end of the last line of the hatch definition
Trang 35By default, acad.pat is in \Documents and Settings\[user name]\Application Data\Autodesk\AutoCAD 2004\R16.0\enu\Support However,your location may be different, depending on your operating system and cus-tomization To find the location of acad.pat, choose Tools ➪ Options and clickthe Files tab Double-click the first item, Support File Search Path, to display thelocation of the support files.
Here is the syntax for hatch patterns:
*pattern-name[, description]
angle, x-origin,y-origin, delta-x,delta-y [, dash1, dash2, ]Here are some general points for hatch pattern definitions:
✦ The pattern name cannot have spaces
✦ The description is optional
✦ Add the dash specifications only for noncontinuous lines
✦ You can have more than one definition line (the second line in the preceding tax), creating sets of hatch definitions that combine to create the hatch pattern
syn-✦ Each definition line can be no more than 80 characters
✦ You can include a maximum of six dash specifications (which include spacesand dots)
✦ You can add spaces in the definition lines for readability
Table 31-2 describes the features of a hatch pattern definition
Table 31-2
Hatch Pattern Definitions
Specification Explanation
Angle Defines the angle of the lines in the hatch pattern If you also specify an
angle in the Boundary Hatch dialog box, the two angles are added For example, if a hatch pattern defines lines at 105 degrees and you specify a hatch angle of 30 degrees, you end up with lines running at 135 degrees X-origin Specifies the X coordinate of the base point of the hatch pattern Although
your hatch probably won’t go through 0,0, AutoCAD uses this point to line up sets of lines in hatch patterns as well as to align hatch patterns in different areas Because all hatch patterns are calculated from the base point, they are always aligned, no matter where they actually appear in the drawing.
Y-origin Specifies the Y coordinate of the base point of the hatch pattern.
Note
Trang 36Specification Explanation
Delta-x Specifies the offset of successive lines This only applies to dashed lines and
is measured along the direction of the lines Specifying a delta-x staggers each successive line by the amount you specify so that the dashes do not line up.
Delta-y Specifies the distance between lines, measured perpendicular to the
direction of the lines This applies to both continuous and dashed lines.
Dash Defines a noncontinuous line using the same system as linetype definitions:
positive for a dash, negative for a space, and zero for a dot.
The hatch pattern shown in Figure 31-6 is the simplest form of hatch pattern
Figure 31-6: The ftrailer hatch
pattern with continuous lines
Although you could specify this simple hatch pattern in the Boundary Hatch dialogbox by specifying a user-defined hatch with an angle and spacing, the example thatfollows shows the syntax clearly The lines are at an angle of 105 degrees, the hatchpattern starts at 0,0, and the spacing between the lines is 0.5 units The lines arecontinuous
*ftrailer, proposed future trailers
105, 0,0, 0,0.5Adding one level of complexity, you can make the lines in the hatch pattern noncon-tinuous, as follows:
*ftrailer, proposed future trailers
105, 0,0, 0,0.5, 5,–.25,0,–.1,0,–.25Note that this definition uses the maximum of six dash specifications (the dash,space, dot, space, dot, and space)
A close-up of this hatch pattern is shown in Figure 31-7
Trang 37Figure 31-7: The ftrailer hatch pattern with a dash and
Trang 38Figure 31-9: Calculating how the delta-x and delta-y affect a hatch pattern
Finally, you can add additional definition lines One of the definition lines shouldstart at 0,0, but the others may start anywhere Here is the definition for the pattern
in Figure 31-10 It actually creates the shape of the trailers Although you see therectangular shape, the hatch pattern is created from four separate lines, two at 0degrees and two at 90 degrees Note that the two 0-degree lines are the same exceptthat they start at different base points The same is true for the two 90-degree lines
*trail, whole trailers-proposed
Trang 39Step-by-Step: Creating and Using a Hatch Pattern
1 Open a drawing using any template.
2 Save the file as ab31-03.dwgin your AutoCAD Biblefolder
3 Type notepad↵and press Enter at the File to edit:prompt
4 Type the following:
*lightning, interwoven lightning
6 If you haven’t already done so, you need to add your AutoCAD Biblefolder
to AutoCAD’s support file search path Choose Tools ➪ Options ➪ Files tab.Click the plus sign to the left of Support File Search Path Choose Add ChooseBrowse Find your AutoCAD Bible folder and click OK Click OK again to closethe Options dialog box
7 Choose Rectangle from the Draw toolbar At the first prompt, type 0,0↵ Atthe Specify other corner point or [Dimensions]:prompt, type 10,6↵
8 Choose Hatch from the Draw toolbar In the Type drop-down list, choose
Custom
9 Click the ellipsis to the right of the Custom Pattern text box Choose the
lightning.patfile you just created Click OK
10 Choose Select Objects and pick the rectangle in your drawing Press Enter.
Click OK AutoCAD fills the rectangle with the lightning hatch, as shown inFigure 31-11
Figure 31-11: The lightning hatch pattern
11 Save your drawing.
Check out AutoCAD’s acad.patfile for some ideas on how to create your ownhatch pattern definitions
Trang 40In this chapter, you discovered how to create your own linetypes and hatch terns You read the following:
pat-✦ Creating simple linetypes containing only dashes, dots, and spaces
✦ Making complex linetypes that include shapes and text
✦ Constructing your own hatch patterns that are made up of a set of parallellines
In the next chapter, you read how to create shapes and fonts