Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 124 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
124
Dung lượng
6,37 MB
Nội dung
saving, loading, and unloading your Customizations | 957 5. Repeat step 4 for each custom component you’ve created. 6. When you’ve copied everything from the left group to the right, click the drop-down list in the Customizations In New File title bar, and select Save As. 7. In the Save As dialog box, enter a name for your customization file, and select a location. 8. Click Save to complete the process. Your customization is saved with the .cuix filename extension. Once it’s saved as a file, you can load it into another copy of AutoCAD by doing the following: 1. Open the Customize User Interface dialog box. 2. Click the Load Partial Customization File tool in the Customizations In All Files group title bar. 3. In the Open dialog box, locate and select your CUI file, and then click Open. 4. Back in the Customize User Interface dialog box, click OK. 5. If your CUI file contains menus, enter Workspace↵↵↵ at the Command prompt. Or select a workspace from the Workspace Switching tool in the status bar. If it contains toolbars, right-click in a blank area next to an existing docked toolbar, and then select the name of your CUI file and the toolbar. As an alternative to using the Customize User Interface dialog box, you can use the CUIload command. Enter Cuiload↵ at the Command prompt to open the Load/Unload Customizations dialog box. Click the Browse button to locate and select your CUI file. Once you’ve done this, the name of your file appears in the File Name input box. You can then click the Load button to import it into your AutoCAD session. Finally, if you want to unload a CUI file, do the following: 1. Open the Customize User Interface dialog box. 2. Scroll down to the bottom of the list in the Customizations In All Files group, and expand the Partial Customization Files item. 3. Right-click the partial CUI file you want to unload, and select Unload name.cuix. 4. Close the dialog box by clicking OK. 621974c28.indd 957 4/26/10 12:41:13 PM 958 | CHAPTER 28 Customizing toolbars, menus, linetypes, and HatCH patterns Understanding the Diesel Macro Language Diesel is one of many macro languages AutoCAD supports, and you can use it to perform sim- ple operations and add some automation to menus. As with AutoLISP, parentheses are used to enclose program code. In the following sections, you’ll look at the different ways to use the Diesel macro lan- guage. You’ll start by using Diesel directly from the command line. This will show you how a Diesel macro is formatted and will give you a chance to see Diesel in action. Then you’ll go on to see how Diesel can be used as part of a menu option to test AutoCAD’s current state. In the third section, you’ll see how Diesel can be used as part of the menu label to control what is shown in the menu. Finally, you’ll learn how to use Diesel with field objects to control text in your drawing. Using Diesel at the Command Line You can use Diesel at the AutoCAD command line by using a command called Modemacro. The Modemacro command sends information to the status bar. Diesel can be used with Modemacro to perform simple tasks. Try the following exercise to experiment with Diesel: 1. At the Command prompt, type Modemacro↵. 2. At the Enter new value for MODEMACRO, or . for none <” “>: prompt, enter $(/,25,2)↵. The answer to the equation appears at far left in the status bar. The answer to the equation appears here. 3. To clear the status bar, enter Modemacro↵.↵. The equation you entered in step 2 is referred to as an expression. The structure of Diesel expressions is similar to that of AutoLISP expressions. The dollar sign tells AutoCAD that the information that follows is a Diesel expression. A Diesel expression must include an operator of some sort, followed by the items to be oper- ated on. An operator is an instruction to take a specific action, such as adding two numbers or dividing one number by another. Examples of mathematical operators include the plus sign (+) for addition and the forward slash (/) for division. The operator is often referred to as a function and the items to be operated on as the arguments to the function, or simply the arguments. In the expression (/,25,2), the / is the function and 25 and 2 are the arguments. All Diesel expressions, no matter what size, follow this structure and are enclosed by parentheses. Parentheses are important elements of an expression. All parentheses must be balanced; for each left parenthesis, there must be a right parenthesis. 621974c28.indd 958 4/26/10 12:41:14 PM understanding tHe diesel maCro language | 959 You can do other things with Diesel besides performing calculations. The Getvar function is an AutoLISP function that you can use to obtain the drawing prefix and name. Try the following to see how Diesel uses Getvar: 1. Type Modemacro↵ again. 2. Type $(getvar,dwgprefix)↵. The location of the current drawing appears in the status bar. 3. Press ↵ to reissue the Modemacro command; then type $(getvar,dwgname)↵. The name of the drawing appears in the status bar. In this example, the Getvar function extracts the drawing prefix and name and displays it in the status bar. You can use Getvar to extract any system variable you want. If you’ve been work- ing through the tutorials in this book, you’ve seen that virtually all AutoCAD settings are also controlled through system variables. (The AutoCAD Help window contains a list of all the sys- tem variables.) This can be a great tool when you’re creating custom menus because with Getvar, you can poll AutoCAD to determine its state. For example, you can find out what command is currently being used. Try the following exercise to see how this works: 1. Click the Line tool on the Draw panel. 2. Type ´Modemacro↵. The apostrophe at the beginning of Modemacro lets you use the command while in another command. 3. Type $(getvar,cmdnames)↵. The word LINE appears in the status bar, indicating that the current command is the Line command. Diesel can be useful in a menu when you want an option to perform a specific task depending on which command is currently active. LT Users Can Use Diesel LT users can’t use AutoLISP to find the location of AutoCAD resource files. However, you can use the Diesel macro language. For example, to find the log file path, enter Modemacro and then $(getvar,logfilepath). The path is displayed in the status bar. To get the status bar tools back, enter Modemacro and then enter a period. Using Diesel in a Custom Menu Macro So far, you’ve been experimenting with Diesel through the Modemacro command. Using Diesel in a menu macro requires a slightly different format. You still use the same Diesel format of a dollar sign followed by the expression, but you don’t use the Modemacro command to access Diesel. Instead, you use $M=. You can think of $M= as an abbreviation for Modemacro. Here’s a Diesel expression that you can use in a menu macro: ^C^C_Blipmode;$M=$(-,1,$(getvar,Blipmode)) This menu option turns Blipmode on or off depending on Blipmode’s current state. As you may recall, Blipmode is a feature that displays point selections in the drawing area as tiny crosses. 621974c28.indd 959 4/26/10 12:41:14 PM 960 | CHAPTER 28 Customizing toolbars, menus, linetypes, and HatCH patterns These tiny crosses, or blips, don’t print and can be cleared from the screen with a redraw. They can be helpful when you need to track your point selections. In this example, the Blipmode command is invoked, and then the $M= tells AutoCAD that a Diesel expression follows. The expression $(-,1,$(getvar,Blipmode)) returns either 1 or a 0, which is applied to the Blipmode command to turn it either on or off. This expression shows that you can nest expressions. The most deeply nested expression is evaluated first, so AutoCAD begins by evaluating $(getvar,Blipmode) This returns either 1 or a 0, depending on whether Blipmode is on or off. Next, AutoCAD evaluates the next level in the expression $(-,1,getvar_result) in which getvar_result is either 1 or a 0. If getvar_result is 1, the expression looks like $(-,1,1) which returns 0. If getvar_result is 0, the expression looks like $(-,1,0) which returns 1. In either case, the end result is that the Blipmode command is assigned a value that is opposite of the current Blipmode setting. Using Diesel as a Menu Bar Option Label In the previous example, you saw how to use Diesel in a menu macro to read the status of a command and then return a numeric value to alter that status. You can also use Diesel as part of the menu bar option name so the text it displays depends on certain conditions. The following expression shows how to write a menu option name to display the current setting for Blipmode. It includes Diesel code as the menu option label: $(eval,Blipmode = $(getvar,blipmode)) Normally, you would just have a menu name, but here you see some Diesel instructions. These instructions tell AutoCAD to display the message Blipmode = 1 or Blipmode = 0 in the menu, depending on the current Blipmode setting. You would place this code in the Properties group for the Blipmode custom command in the Customize User Interface dialog box. It goes in the Display/Name input box. 621974c28.indd 960 4/26/10 12:41:14 PM understanding tHe diesel maCro language | 961 Here’s how it works. You see the familiar $(getvar,blipmode) expression, this time embed- ded in a different expression. You know that $(getvar,blipmode) returns either 1 or a 0, depending on whether Blipmode is on or off. The outer expression $(eval,Blipmode = getvar_result) displays Blipmode = and then combines this with getvar_result, which, as you’ve learned, will be either 1 or 0. The eval function evaluates any text that follows it and returns its contents. The end result is the appearance of Blipmode = 1 or Blipmode = 0 in the menu, depending on the status of Blipmode. Here’s how the properties looks as a menu bar option under the Tools list of the Menus option in the Customizations In All Files panel. You can get even fancier and set up the menu option label to read Blipmode On or Blipmode Off by using the if Diesel function. Here’s that same menu listing with additional Diesel code to accomplish this: $(eval,Blipmode = $(if,$(getvar,blipmode),Off,On)) In this example, the simple $(getvar,blipmode) expression is expanded to include the if function. The if function reads the result of $(getvar,blipmode) and then returns the Off or On value depending on whether $(getvar,blipmode) returns 0 or a 1. Here’s a simpler look at the expression: $(if, getvar_result, Off, On) If getvar_result returns 1, the if function returns the first of the two options listed after getvar_result, which is Off. If getvar_result returns 0, the if function returns On. The second of the two options is optional. Here’s how the fancier Blipmode option appears in a menu. You’ve just skimmed the surface of what Diesel can do. To get a more detailed description of how Diesel works, press the F1 function key to open the AutoCAD 2011 Help website. Click the Contents tab, expand the Customization Guide listing, and click the DIESEL listing that appears. Table 28.2 shows some of the commonly used Diesel functions. Check the AutoCAD Help dialog box for a more detailed list. Table 28.2: Sample of Diesel functions Code Function Example result Comments + Add $(+,202,144) 346 – Subtract $(-,202,144) 58 621974c28.indd 961 4/26/10 12:41:15 PM 962 | CHAPTER 28 Customizing toolbars, menus, linetypes, and HatCH patterns Code Function Example result Comments * Multiply $(*,202,144) 29,088 / Divide $(/,202,144) 1.4028 = Equal to $(=,202,144) 0 If numbers are equal, 1 is returned. < Less than $(<,202,144) 0 If the first number is less than the second, 1 is returned. > Greater than $(>,202,144) 1 If the first number is greater than the second, 1 is returned; otherwise 0 is returned. ! Not equal to $(!,202,144) 1 If the numbers are equal, 0 is returned. <= Less than or equal to $(<=,202,144) 0 If the first number is less than or equal to the sec- ond, 1 is returned. >= Greater than or equal to $(>=,202,144) 1 If the first number is greater than or equal to the second, 1 is returned; otherwise 0 is returned. eq Equal string $(eq,Yes, No) 0 If both text strings are the same, 1 is returned. eval Evaluate text $(eval,Here I Am) Here I Am Returns the text that follows. getvar Get system variable value $(getvar,ltscale) Current linetype scale Returns the value of the system variable. if If/Then $(if,1,Yes,No) Yes The second argument is returned if the first argument evaluates to 1. Otherwise, the third argu- ment is returned. The third argument is optional. Note: To indicate true or false, Diesel uses 1 or 0. Table 28.2: Sample of Diesel functions (continued) 621974c28.indd 962 4/26/10 12:41:15 PM understanding tHe diesel maCro language | 963 Using Diesel and Fields to Generate Text Using Diesel expressions in the status bar or in a menu can be helpful to gather information or to create a more interactive interface, but what if you want the results of a Diesel expression to become part of the drawing? You can employ field objects to do just that. For example, suppose you want to create a note that shows the scale of a drawing based on the dimension scale. Further, you want the scale in the note to be updated automatically whenever the dimension scale changes. You can add a field object and associate it with a Diesel expression that displays the dimension scale as it relates to the drawing scale. Try the following steps to see how it’s done: 1. In the Annotate tab, click the Multiline Text tool and select two points to indicate the text location. The Text Editor Ribbon tab and text editor appear. 2. Right-click in the text editor, and select Insert Field to open the Field dialog box. 3. In the Field Category drop-down list, select Other; then, in the Field Names list box, select DieselExpression. 4. Add the following text in the Diesel Expression box to the right. If you need to expand the width of the dialog box, click and drag its right edge: $(eval,Dimension Scale: 1/)$(/,$(getvar, dimscale),12)$(eval, inch = 1 foot) 5. Click OK in the Field dialog box, and then click Close Text Editor in the Text Editor Ribbon tab. The following text is displayed in the drawing: Dimension Scale: 1/0.08333333 inch = 1 foot The resulting text may not make sense until you change the dimension scale to a value that represents a scale other than 1-to-1. Here’s how to do that: 1. Enter Dimscale↵ at the Command prompt. 2. At the Enter new value for DIMSCALE <1.0000>: prompt, enter 96. This is the value for a 1⁄8˝ scale drawing. 3. Type Re↵. The text changes to read Dimension Scale: 1⁄8 inch = 1 foot In this example, several Diesel operations were used. The beginning of the expression uses the eval operation to tell AutoCAD to display a string of text: $(eval Dimension Scale: 1/) The next part tells AutoCAD to get the current value of the Dimscale system variable and divide it by 12: $(/,$(getvar, dimscale),12) Notice that this is a nested expression: $(getvar,dimscale) obtains the value of the Dimscale system variable, which is then divided by 12. The end of the expression adds the final part to the text: $(eval, inch = 1 foot) 621974c28.indd 963 4/26/10 12:41:15 PM 964 | CHAPTER 28 Customizing toolbars, menus, linetypes, and HatCH patterns When it’s all put together, you get the text that shows the dimension scale as an architectural scale. Because it’s an AutoCAD text object, this text is part of the drawing. Creating Custom Linetypes As your drawing needs expand, the standard linetypes may not be adequate for your applica- tion. Fortunately, you can create your own. The following sections explain how to do so. You’ll get an in-depth view of the process of creating linetypes. You’ll also learn how to cre- ate complex linetypes that can’t be created by using the Make Linetype Express tool. Viewing Available Linetypes Although AutoCAD provides the linetypes most commonly used in drafting (see Figure 28.23), the dashes and dots may not be spaced the way you would like, or you may want an entirely new linetype. Figure 28.23 The lines in this list of standard linetypes were generated with the underscore key (_) and the period (.) and are only rough repre- sentations of the actual lines. 621974c28.indd 964 4/26/10 12:41:15 PM Creating Custom linetypes | 965 Where Are the Linetypes Stored? AutoCAD stores the linetypes in a file called acad.lin, which is in ASCII format. When you create a new linetype, you add information to this file. Or, if you create a new file containing your own linetype definitions, it too will have the extension .lin at the end of its name. You can edit linetypes as described here, or you can edit them directly in these files. To create a custom linetype, use the Linetype command. Let’s see how this handy command works by first listing the available linetypes: 1. Open a new AutoCAD file. 2. At the Command prompt, enter –Linetype↵. (Don’t forget the minus sign at the beginning.) 3. At the Enter an option [?/Create/Load/Set]: prompt, enter ?↵. 4. In the dialog box, locate and double-click acad.lin in the listing of available linetype files. You get a list that shows the linetypes available in the acad.lin file along with a simple description of each line. 5. A message at the bottom says Press ENTER to continue:. Do so until you see the Command prompt. Creating a New Linetype Next, let’s try creating a new linetype: 1. Enter –Linetype↵ again. 2. At the [?/Create/Load/Set]: prompt, enter C↵. 3. At the Enter name of linetype to create: prompt, enter Custom↵ as the name of your new linetype. 4. The dialog box you see next is named Create Or Append Linetype File. You need to enter the name of the linetype file you want to create or add to. If you select the default linetype file, acad, your new linetype is added to the acad.lin file. If you choose to create a new linetype file, AutoCAD opens a file containing the linetype you create and adds .lin to the filename you supply. 5. Let’s assume you want to start a new linetype file. Enter Newline↵ in the File Name input box. New or Existing Linetype File If you accept the default linetype file, acad, the prompt in step 4 is Wait, checking if linetype already defined. … This protects you from inadvertently overwriting an existing linetype you want to keep. 621974c28.indd 965 4/26/10 12:41:16 PM 966 | CHAPTER 28 Customizing toolbars, menus, linetypes, and HatCH patterns 6. At the Descriptive text: prompt, enter a text description of your linetype. You can use any keyboard character as part of your description, but the actual linetype can be composed of only a series of lines, points, and blank spaces. For this exercise, enter the following, using the underscore key (_) to simulate the appearance of your line: Custom – My own center line __________ _ ____________ ↵ 7. At the Enter linetype pattern (on next line): prompt, enter the following num- bers, known as the linetype code (after the A, that appears automatically): 1.0, 125,.25, 125↵ You Can Set the Default Linetype If you use the Set option of the -Linetype command to set a new default linetype, you’ll get that linetype no matter what layer you’re on. 8. At the New linetype definition saved to file. Enter an option [?/Create/ Load/Set]: prompt, press ↵ to exit the -Linetype command. Remember, after you’ve created a linetype, you must load it in order to use it, as discussed in Chapter 5. Add Linetypes Directly to the acad.lin File You can also open the acad.lin or other LIN file in Windows Notepad and add the descriptive text and linetype code directly to the end of the file. Understanding the Linetype Code In step 6 of the previous exercise, you entered a series of numbers separated by commas. This is the linetype code, representing the lengths of the components that make up the linetype. The separate elements of the linetype code are as follows: The •u 1.0 following the A is the length of the first part of the line. (The A that begins the line- type definition is a code that is applied to all linetypes.) The first •u 125 is the blank or broken part of the line. The minus sign tells AutoCAD that the line is not to be drawn for the specified length, which is 0.125 units in this example. Next comes the positive value •u 0.25. This tells AutoCAD to draw a line segment 0.25 units long after the blank part of the line. The last negative value, •u 125, again tells AutoCAD to skip drawing the line for the distance of 0.125 units. 621974c28.indd 966 4/26/10 12:41:16 PM [...]... which can be found in the Chapter 29 folder of the sample files You see two new items, Sample House Alt-Model and Sample House Alt-Alternate Plan, in the list box These are the layout and Model views that are in the sample house alt.dwg file 62 197 4c 29. indd 98 5 4/26/10 12:41:27 PM | Chapter 29 98 6 Managing and Sharing Your Drawings Automatically Excluding Layouts In step 2 of the previous exercise, the... Relative Path For Hyperlink option isn’t selected, and then click OK The link you just created is stored with the drawing file You can create a DWF file from this drawing and the link will be preserved in the DWF file 62 197 4c 29. indd 99 1 4/26/10 12:41: 29 PM | Chapter 29 99 2 Managing and Sharing Your Drawings Now let’s see how you can use the link from within the AutoCAD file: 1 Move your cursor over the... have major repercussions to the integrity of a design 62 197 4c 29. indd 97 9 4/26/10 12:41:25 PM | Chapter 29 98 0 Managing and Sharing Your Drawings AutoCAD 2011 offers tools that can help minimize file tampering The eTransmit feature offers a password-protection option to reduce the possibility of unauthorized tampering with transmittal files AutoCAD also offers password protection for individual files... a file insertion AutoCAD Remembers That You’ve Opened a File After you open a password-protected file and give the password, you can open and close the file repeatedly during that AutoCAD session without having to reenter the password If you close and reopen AutoCAD, AutoCAD will prompt you for a password the next time you attempt to open the password-protected file 62 197 4c 29. indd 98 0 4/26/10 12:41:26... with 69 patterns and that was only scratching the surface Adding Thick Lines to Linetypes If you want to include thick lines in your hatch patterns, you have to build up line widths with multiple linetype definitions 62 197 4c28.indd 97 1 4/26/10 12:41: 19 PM 97 2 | Chapter 28 Customizing Toolbars, Menus, Linetypes, and Hatch Patterns Figure 28.32 The distance and direction of duplication Direction 90 0.125... sheet name and selecting a page setup from the list box that appears in the Page Setup column 62 197 4c 29. indd 98 7 4/26/10 12:41:28 PM 98 8 | Chapter 29 Managing and Sharing Your Drawings To change the page setup for multiple sheets, select the sheets from the list first and then select the setup from the list box If you happen to have two layouts with the same name, right-click a layout name, and then... network, and even to documents on other sites Creating Hyperlinks The following shows you how to add links to a sample floor plan: 1 In AutoCAD, open the file houseplan.dwg 2 In the Insert tab’s Data panel, click the Hyperlink tool 62 197 4c 29. indd 99 0 4/26/10 12:41: 29 PM | ePublishing Your Drawings 99 1 3 At the Select objects: prompt, click on the hexagonal door symbol, as shown in Figure 29. 11 Figure 29. 11... tools AutoCAD provides for publishing and accessing drawings over the Internet (and on any local or wide area network) You’ll start by looking at one of the most common uses of the Internet: file transmission 62 197 4c 29. indd 97 5 4/26/10 12:41:24 PM | Chapter 29 97 6 Managing and Sharing Your Drawings Sharing Project Files with eTransmit Perhaps the most common use of the Internet is sending and receiving... boundary for your DWF file You can also specify whether to include layer and font information 6 Click OK after selecting your settings The Plotter Configuration Editor dialog box reappears After you’ve set the custom properties, you can save any new settings in 62 197 4c 29. indd 98 9 4/26/10 12:41:28 PM | Chapter 29 99 0 Managing and Sharing Your Drawings the DWF6 ePlot.pc3 file, or you can create a new... can enter the date and time and a comment for the files you’ve selected 5 Click Sign Files when you’re sure you’ve selected the correct files and entered an appropriate comment If you exchange AutoCAD drawings regularly with clients and consultants, you’ll want to obtain a digital ID and use AutoCAD s digital signature feature Be aware, however, that because this feature was new in AutoCAD 2004, it . 28. 29 The Arrowline linetype used with a spline 62 197 4c28.indd 96 9 4/26/10 12:41:18 PM 97 0 | CHAPTER 28 Customizing toolbars, menus, linetypes, and HatCH patterns Creating Hatch Patterns AutoCAD. transmission. 62 197 4c 29. indd 97 5 4/26/10 12:41:24 PM 97 6 | CHAPTER 29 Managing and Sharing Your drawingS Sharing Project Files with eTransmit Perhaps the most common use of the Internet is sending and receiving. described Figure 28.25 Random broken line Figure 28.26 AutoCAD stretches the beginning and the end of the line as necessary. StretchedStretched 62 197 4c28.indd 96 7 4/26/10 12:41:17 PM 96 8 | CHAPTER