Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 130 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
130
Dung lượng
1,45 MB
Nội dung
998 Part VI ✦ Customizing AutoCAD Here are the other features of the Button Editor: ✦ Click Clear to clear the editing area and start from scratch. ✦ Click Open to open an existing button for editing. Button icons are stored as BMP files. ✦ Click Undo to undo your most recent action. ✦ Click Save As to save an existing BMP file under a new name. If you create a new (or edited) button, use the Save As button and remember where you saved the BMP file. The default is the main Support File Search Path location, which you can find on the Files tab of the Options dialog box (Tools➪ Options). ✦ Click Save to save the button icon as a BMP file. The default filename is ICON.bmp. ✦ Click Close to close the Button Editor. ✦ Click More to select a standard index color or true color. (True colors are available in AutoCAD only.) If you edited an existing button and saved the changes, then you’re done. However, if you saved your button image under another file name (using the Save As button), you need to associate the new filename with the toolbar button. In the Properties pane, click the Small Image text box, and then click the Ellipsis (. . .) button. Browse to the BMP file and choose it. Click Open. The file location appears in the Small Image text box. You can now click Apply, or if you want to return to your drawing, click OK. If you think you might ever want to display large toolbar buttons, do the same for the Large Image text box. By default, when you create a button image, the Both option button is selected in the Button Image section, and so you create both a small and a large image. To display large toolbar buttons, choose Tools ➪ Options and click the Display tab. In the Window Elements section, check the Use Large Buttons for Toolbars check box. Creating flyouts You can use the Customize User Interface dialog box to create your own flyouts, or you can use one of the existing flyouts. To use an existing flyout, you just drag one toolbar onto another one. Expand the Toolbars item in the Customizations In pane. Then expand the tool- bar that you want to work with. In the same pane, locate the toolbar that you want to turn into a flyout, and drag it to any location on the expanded toolbar. To create your own flyout from scratch, follow these steps: 1. Expand the Toolbars item in the Customizations In pane. 2. Right-click any toolbar and choose New ➪ Flyout. 3. Right-click the new flyout (named Toolbar1 by default) and choose Rename. Type a name for the flyout. 4. From the Command List pane, drag commands to the flyout, using the same technique as described in the “Adding buttons” section earlier in this chapter. The following exercise loads a partial customization file on top of the main customization file. After the exercise, I explain how to undo the changes if you want. If you’re working on some- one else’s computer, don’t do this exercise without that person’s permission. I explain more about main and partial customization files in Chapter 33. 40_788864 ch29.qxp 5/22/06 7:38 PM Page 998 999 Chapter 29 ✦ Customizing Commands, Toolbars, and Tool Palettes STEPS: Customizing Toolbars 1. Open Windows Explorer. Copy acad.cui (for AutoCAD) or acadlt.cui (for AutoCAD LT) to a floppy disk, a CD-ROM, or your AutoCAD Bible folder as a backup. If you use a folder on your hard drive, be sure to press the Ctrl key as you drag the file so that you copy it instead of moving it. If you don’t do this step, you won’t have a way to undo the changes that you make to the menu file. To find the location of these files, choose Tools ➪ Options and click the Files tab. Double-click the Customization Files item, and then double-click the Main Customization File item to dis- play the location of the menu file. 2. Start a new drawing using any template. Save the file as ab29-01.dwg in your AutoCAD Bible folder. 3. Choose Tools➪ Customize ➪ Interface to open the Customize User Interface dialog box. You should see All Customization Files in the drop-down list. Double-click the Toolbars item to expand it. Scroll down, and double-click the Zoom toolbar to expand it. 4. To delete a button from the Zoom toolbar, right-click the Zoom Center button (or the button that you use least) and choose Delete. Confirm the deletion. Note that you can preview the results in the Preview pane by clicking the toolbar name. Double-click the Toolbars item again to collapse it. Click the Save All Current Customization Files button to the right of the drop-down list. 5. To create a new toolbar, start by creating a new partial customization file. Click the Transfer tab of the Customize User Interface dialog box. 6. From the drop-down list in the Customizations in Main CUI (left) pane, choose New. From the drop-down list, choose Save As. In the Save As dialog box, type ab29-01 in the File Name text box and click Save. (This saves the file in the Support folder, which is the default location for CUI files.) 7. To load the new partial customization file, ab29-01.cui, click the Customize tab. Make sure that All Customization Files shows in the Customizations In pane’s drop-down list. If it doesn’t, choose it. To the right of the drop-down list, click the Load Partial Customization File button. In the Open dialog box, choose ab29-01.cui and click Open. You see the filename in the drop-down list. You may see a warning that workspace information in partial CUI files is ignored. This file doesn’t have any workspace information in it, so click OK. I discuss workspaces in Appendix A. 8. To check that the new partial CUI file is loaded along with the main CUI file, choose Main CUI File from the drop-down list. Double-click the Partial CUI files item. You should see ab29-01 on the list. 9. In the Customizations In pane, choose All Customization Files from the drop-down list. Double-click the Partial CUI Files item and then double-click the AB29-01 item. Right-click the Toolbars item and choose New➪ Toolbar. Type Special and press Enter. (If the toolbar name is not selected and editable, right-click the new toolbar and choose Rename. Then enter the new name.) Note Note 40_788864 ch29.qxp 5/22/06 7:38 PM Page 999 1000 Part VI ✦ Customizing AutoCAD 10. From the Command list drop-down list, choose All Commands. Find the Donut item and drag it to the new Special toolbar. You should see a left-pointing arrow when you have dragged the command onto the toolbar. 11. From the Categories drop-down list in the Command List pane, choose the Modify cate- gory and find Polyline. (This is the PEDIT command.) Drag it to your new toolbar. To find a command in the long list, click any command and type the first letter of the com- mand you want. The list jumps to the first command with that letter. You can then scroll down and quickly find the command you want. 12. With All Commands displayed in the Categories List, drag the HIDE command (or Hidden Visual Style) to the toolbar. 13. To create a custom command, click the New button to the right of the Categories drop- down list. You see the new command listed as Command1 in the Properties pane. 14. Complete the Properties pane as shown in Figure 29-9. Type the macro as follows after the ^C^C (which is already there), being careful to also include the spaces: pedit \w .1 ; 15. Select the Special toolbar item. From the Categories drop-down list, choose Custom Commands. Drag the pline_tenth command to the Special toolbar. 16. With the pline_tenth button selected, in the Button Image pane, click the PEDIT icon. (It looks similar to the icon in Figure 29-10.) Then choose Edit to open the Button Editor. Figure 29-9: The completed Properties pane for the custom command. 17. 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. Click the red color. Choose the Pencil tool (by default, it is already chosen). Click the Grid check box to help you work. Click (or drag) the point of the Pencil tool in each box, using Figure 29-10 as a guide. (Figure 29-10 shows the button in black and white.) When you’re done, click Save. Tip 40_788864 ch29.qxp 5/22/06 7:38 PM Page 1000 1001 Chapter 29 ✦ Customizing Commands, Toolbars, and Tool Palettes If you make a mistake, it’s easy to correct it. If you place a red pixel over an existing black pixel, choose black and redraw the black pixel. If you place a red pixel in a wrong spot, choose the Erase tool and click the pixel. 18. In the Create File dialog box, type pline_tenth in the File Name text box and click Save. (Note that the file is saved in the Support\Icons folder by default.) Click Close. Figure 29-10: You can create a new button in the Button Editor. 19. To assign the icon to the button, in the Properties pane, click the Small Image item, and then click the Ellipsis button to the right. In the Support\Icons folder where you saved the icon file, choose pline_tenth.bmp and click Open. (If you are using large icons, use the Large Image item instead, or assign the icon to both.) 20. Click Apply. If necessary, move the dialog box so that you can see the new toolbar. If it seems okay, click OK to close the Customize User Interface dialog box. (If not, continue to make changes in the dialog box.) The toolbar should look like Figure 29-11. If you don’t see the toolbar when you close the Customize User Interface dialog box, right- click in any empty toolbar area (off all toolbars) and choose AS29-01 ➪ Special to display the toolbar. Figure 29-11: The custom toolbar contains four buttons. 21. Choose Polyline from the Draw toolbar and draw any series of polyline segments. Choose the Pline_tenth button from the new toolbar. At the Select polyline or [Multiple]: prompt, pick the polyline. Its width changes to 0.1. (If it doesn’t work, return to the Customize User Interface dialog box and check the macro.) 22. Save your drawing. Note Tip 40_788864 ch29.qxp 5/22/06 7:38 PM Page 1001 1002 Part VI ✦ Customizing AutoCAD Here’s how the pedit macro that you used in the previous exercise works: pedit \w .1 ; 1. Pedit issues the PEDIT command. The space after pedit is equivalent to pressing Enter after you’ve typed the command on the command line. The PEDIT command 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 an option [Close/ Join/Width/Edit vertex/Fit/Spline/Decurve/Ltype gen/Undo]: prompt. 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-12. The current tool palettes are listed. Remember that each tab on the Tool Palette window is considered a separate tool palette. Undoing Toolbar Changes To undo the changes that you made, you need to take two steps. To unload the partial cus- tomization file, right-click it in the Customize User Interface dialog box and choose Unload. Confirm the decision. This file is separate from the main customization file, and so it doesn’t affect the main customization file directly. To undo the changes that you made to the main customization file ( acad.cui or acadlt.cui), you need to copy the original file over the new one. To find the location of this file, choose Tools ➪ Options and click the Files tab. Double-click the Customization Files item, and then double-click the Main Customization File item. Close AutoCAD. In Windows Explorer, locate the backup copy that you made in Step 1 of the pre- vious exercise. Expand the location of the current main customization file. Press Ctrl and drag the backup file to the current file of the same name. When you open AutoCAD again, it will load the backup copy of the main customization file. 40_788864 ch29.qxp 5/22/06 7:38 PM Page 1002 1003 Chapter 29 ✦ Customizing Commands, Toolbars, and Tool Palettes Figure 29-12: 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. ✦ 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-12. Note that the tool palettes come with a large number of dynamic blocks, and materials (AutoCAD only). 40_788864 ch29.qxp 5/22/06 7:38 PM Page 1003 1004 Part VI ✦ Customizing AutoCAD 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 acadlt.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. ✦✦✦ 40_788864 ch29.qxp 5/22/06 7:38 PM Page 1004 30 30 CHAPTER Creating Macros and Slide Shows with Script Files S cript 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. By running a script file on a number of drawings, you can complete a time-consuming task in a fraction of the time. If you need to put together just a few commands that you might use another time for other drawings, you may want to consider creating a menu item or toolbar button instead. Chapter 29 explains how to cus- tomize 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 exe- cute, 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 filename extension. ✦ They are text-only (ASCII) files. ✦ They must use command-line syntax only (which can include AutoLISP expressions). 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 ✦✦✦✦ In This Chapter Automating commands with script files Creating slide shows Creating slide libraries for menu customization ✦✦✦✦ 41_788864 ch30.qxp 5/22/06 7:32 PM Page 1005 1006 Part VI ✦ Customizing AutoCAD 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.) ✦ If the script includes commands that open a dialog box that asks for files, set the sys- tem 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 dia- log 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. Script files automatically run as if FILEDIA were off, even if it’s set to 1 (on). The FILEDIA sys- tem variable determines whether dialog boxes appear for commands that let you open or select files. ✦ For commands that require inputting text such as layer names or filenames, 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 filename, 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. Note 41_788864 ch30.qxp 5/22/06 7:32 PM Page 1006 1007 Chapter 30 ✦ Creating Macros and Slide Shows with Script Files Figure 30-1: Running a script file created this drawing. Taking Script Files to the Max What if you want to execute that multi-cleanup script file on 200 drawings? Typing in all of those filenames would take so long that you would wonder if you were saving any time. However, you can save time. First, you need to find a text editor or word processor that can cre- ate vertical 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. (Use a fixed- width font, such as Courier New, to make selecting columns of text easier.) Then, you need to format the script file so that the entire set of commands is in one row, as in the figure shown here. In Microsoft Word, you can use Page Setup to set the paper to landscape and make it as wide as you need so that the text doesn’t wrap. (Of course, you type the script once, and then copy the line and paste it as many times as you need.) You do this so that all of the filenames will be in one column. Here you see the path but no filename at the end of each line. The filename will be inserted before the quotation mark at the end of each line. Now, open a DOS window. (From the Windows taskbar, choose Start ➪ Programs➪ Accessories ➪ Command Prompt.) Use the DOS cd command to navigate to the folder where all of your drawings are located. (They should all be in one folder.) Type dir *.dwg /b >dwglst.txt and press Enter. This creates a listing of all of the files in that folder, and places it in a text file named dwglst.txt. The /b parameter 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 vertical block over the drawing names and copy it to the Clipboard. Open the script file in the same text editor or word processor, place the cursor at the top-left cor- ner of the vertical block, and paste. You should get all of the drawing names inserted in the right place, as shown here with two drawings. If you’re in a word processor, don’t forget to save the file as a Text Only document. Used in this way, the script files feature can be an extremely powerful tool for editing large num- bers of drawings in one batch. 41_788864 ch30.qxp 5/22/06 7:32 PM Page 1007 [...]... 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... being generated up and to the left The first line starts at 0,0, and the second line starts to the left by 0.5 units (the delta-y) and up by 0.25 units (the delta-x), as shown by the dimensions Figure 3 1-8 : The ftrailer hatch pattern with an added delta-x 1023 42_788864 ch31.qxp 1024 5/22/06 7:37 PM Page 1024 Part VI ✦ Customizing AutoCAD Figure 3 1 -9 : Calculating how the delta-x and delta-y affect a hatch... CD-ROM The drawing used in the following exercise on creating and viewing slides, ab30-b.dwg, is in the Drawings folder on the CD-ROM STEPS: Creating and Viewing Slides 1 Open ab30-b.dwg from the CD-ROM 2 Save the file as ab3 0-0 2.dwg in your AutoCAD Bible folder 3 Type hide ↵ to hide the drawing 4 Type mslide ↵ In the Create Slide File dialog box, click the Save In drop-down menu and select your AutoCAD. .. Figure 3 0-2 Figure 3 0-2 : The Shortcut tab of the AutoCAD 2007 Properties dialog box 41_788864 ch30.qxp 5/22/06 7:32 PM Page 10 09 Chapter 30 ✦ Creating Macros and Slide Shows with Script Files 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... 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 3 0-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 3 0-3 : A script file that... Linetype File dialog box, find ab3 1-0 1.lin in your AutoCAD Bible folder, 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 then click OK The layer tfence now shows the correct linetype Click Current and then click OK 11 Start the LINE command and turn on ORTHO Draw any line... creating and using a script file similar to the multicleanup script file used in the previous example, but for only one drawing On the CD-ROM The drawing used in the following exercise on creating and using a script file, ab30-a.dwg, 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 ab3 0-0 1.dwg in your AutoCAD Bible folder... 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 2007\ acad.exe and you want to open a drawing named ba-3 49. dwg in c:\drawings and run a script file named pre-plot.scr, your target should read: “C:\Program Files \AutoCAD. .. types of linetypes: simple and complex Simple linetypes consist of only dashes and dots Complex linetypes usually have dashes and/ or dots, but also contain text and/ or shapes The default linetype file is acad.lin for AutoCAD and acadlt.lin for AutoCAD LT You can add your own linetype definitions to this file or create your own linetype files Linetype files are text files and must have a lin file extension... Creating a Slide Show 1 Open Notepad and type the following script: vslide ab3 0-0 2a vslide *ab3 0-0 2b delay 3000 vslide vslide *ab3 0-0 2c delay 3000 vslide delay 3000 rscript 2 Remember to press Enter at the end of the last line Save the file as ab3 0-0 2.scr in your AutoCAD Bible folder Close Notepad 3 To ensure that AutoCAD can find the slide files, place your AutoCAD Bible folder in the support file search . Page 99 8 99 9 Chapter 29 ✦ Customizing Commands, Toolbars, and Tool Palettes STEPS: Customizing Toolbars 1. Open Windows Explorer. Copy acad.cui (for AutoCAD) or acadlt.cui (for AutoCAD LT) to. open AutoCAD or AutoCAD LT. The easiest way to do this is to use the short- cut to AutoCAD or AutoCAD LT on your desktop and modify the target there. Right-click the AutoCAD or AutoCAD LT shortcut. reducing menu and command-line space. You can use the CLEANSCREEN command (press Ctrl+0) to toggle the toolbars and palette windows on and off. You can also hide (and redisplay) the com- mand-line window