AUGIWorld Magazine November/December 2007 - (Page 22) function allows you to enter text at the command prompt; as the user enters the text you are entering, you can either allow or disallow them from entering spaces into the text string. Below are two examples of using the GETSTRING function. The first example does not allow the user to enter spaces while the second one does. The use of the space bar is controlled by the T variable in the second To dialog or not to dialog example. Just like the other Get* functions, you can provide an optional Dialog boxes play a role in collecting input from user message. the user in AutoCAD, but they don’t allow you to (setq TXT (getstring “\nEnter a text string: “)) create predictable AutoLISP routines. Many of the (setq TXT2 (getstring T “\nEnter a text string: “)) commands in AutoCAD that utilize dialog boxes for collecting input have alternate commands that Getreal and Getint work from the command prompt. In some cases Both the GETREAL and GETINT functions allow you to prompt the user you will need to learn about the system variables in for a numeric value. If the user enters a text string, they will be informed that AutoCAD. The alternate commands that work they must enter a number value. Like the other Get* functions, you can profrom the command line often begin with a hyvide an optional message to the user. phen. For example, the HATCH command dis(setq REAL (getrealpoint “\nEnter a real number: “)) plays the Hatch and Gradient dialog box while the (setq INT (getint “\nEnter an integer: “)) –HATCH command offers most of the options that are used for creating hatched areas from the Getkword and Initget Keywords are a powerful form of input in AutoCAD and they are used a Command prompt. In some cases, the command line version of lot with commands that work from the Command Line or Dynamic Input tooltips. When you start a command such as CIRCLE, you have the ability a command might not be the best option to use to specify the center point of the circle or enter an option. The options for a or there might not be a command line version of the command that you want to use. If you need command prompt are based on predefined keywords. To prompt the user for a keyword, you use the GETKWORD function or to display a dialog box during the execution of an one of the other Get* functions with the exception of GETSTRING. Before AutoLISP routine, you can use the INITDIA funcyou can use keywords you must use the INITGET function to define the key- tion before calling the command with the COMwords that you want to use for the next Get* function. When you define your MAND function. The following example shows how keywords, you need to uppercase the letters that you need the user to enter to use the INITDIA function in combination with the LAYER command. in order to use the option. In the following example, two keywords start with O so the next letter is ;; Example uses the LAYER command from the command line (command “_-layer” “_make” “Text” “”) also capitalized to make sure AutoCAD knows what the user needs to enter. If the user was to enter just O, a message will be displayed that mentions that an ;; Example uses the LAYER command with the dialog box (initdia) ambiguous response was entered and for them to try again. To make your routines multipurpose and scalable, you should prompt the user for input in the form of a string, number, or point. (initget “Apple ORange Grapes OTher“) (setq KWORD (getkword “\nPick a type of fruit [Apple/ORange/Grapes/OTher]: “)) (command “_layer”) The following example shows using GETPOINT with keywords like the Using static values in your AutoLISP routines is great initial prompt of the CIRCLE command. for performing repetitive tasks that are the same over and (initget “3P 2P Ttr (tan tan rad)“) (getpoint “\Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: “) over again, but this approach does not work very well if a value needs to be changed each time the routine is used. Note: The INITGET function allows you to control the Get* functions in a To make your routines multipurpose and scalable, you variety of different ways. To learn about the additional options for the INIT- should prompt the user for input in the form of a string, number, or point. While using static values has its place, GET function, see the online help system that comes with AutoCAD. Note: For user messages with keywords, make sure that you list the available getting input brings your routines to the next level by options in [] and separate each one with a forward slash. This will automatically giving the user some control over the desired results. allow AutoCAD to display the options on the shortcut menu or the Dynamic Input menu. Lee Ambrosius is a consultant for HyperPics, LLC an AutoCAD Consulting/ Training company located in Wisconsin, USA. He specializes in AutoCAD Customization/Programming with AutoCAD R12 through 2008. He is one of the co-authors of the book AutoCAD & AutoCAD LT All-in-One Desk Reference For Dummies (based on AutoCAD 2007) and is the author of the book AutoCAD 2008 3D Modeling Workbook For Dummies. Lee can be reached via e-mail at lee_ambrosius@hyperpics.com; other contact information can be found on his website at http://www.hyperpics.com or his blog at http://hyperpics.blogs.com. w w w. A U G I . c o m Conclusion Time to pause When working with commands in AutoCAD such as LINE or INSERT you may want to ask the user for a point or a scale factor. Since the command already understands what type of input it needs, you can use the variable PAUSE instead of using one of the Get* functions to request input from the user. The following example shows how to use PAUSE with the LINE command to allow the user to create a closed three-sided object. (command “._line” PAUSE PAUSE PAUSE “_close”) 22 http://www.hyperpics.com http://hyperpics.blogs.com http://www.AUGI.com
Table of Contents Feed for the Digital Edition of AUGIWorld Magazine November/December 2007 AUGIWorld Magazine November/December 2007 Table of Contents The CAD Manager Education & Training Finance Training Google Earth: Now Showing in AutoCAD Civil 3D Get Your Input Here A Good First Impression, Part 2 Share and Share Alike Who's Using Revit MEP? Ready… Get Set… Properties! On the Back Page: The Brazilian Model AUGIWorld Magazine November/December 2007 AUGIWorld Magazine November/December 2007 - AUGIWorld Magazine November/December 2007 (Page Cover1) AUGIWorld Magazine November/December 2007 - AUGIWorld Magazine November/December 2007 (Page Cover2) AUGIWorld Magazine November/December 2007 - AUGIWorld Magazine November/December 2007 (Page 1) AUGIWorld Magazine November/December 2007 - Table of Contents (Page 2) AUGIWorld Magazine November/December 2007 - Table of Contents (Page 3) AUGIWorld Magazine November/December 2007 - The CAD Manager (Page 4) AUGIWorld Magazine November/December 2007 - The CAD Manager (Page 5) AUGIWorld Magazine November/December 2007 - Education & Training (Page 6) AUGIWorld Magazine November/December 2007 - Education & Training (Page 7) AUGIWorld Magazine November/December 2007 - Education & Training (Page 8) AUGIWorld Magazine November/December 2007 - Education & Training (Page 9) AUGIWorld Magazine November/December 2007 - Finance Training (Page 10) AUGIWorld Magazine November/December 2007 - Finance Training (Page 11) AUGIWorld Magazine November/December 2007 - Finance Training (Page 12) AUGIWorld Magazine November/December 2007 - Finance Training (Page 13) AUGIWorld Magazine November/December 2007 - Finance Training (Page 14) AUGIWorld Magazine November/December 2007 - Finance Training (Page 15) AUGIWorld Magazine November/December 2007 - Finance Training (Page 16) AUGIWorld Magazine November/December 2007 - Finance Training (Page 17) AUGIWorld Magazine November/December 2007 - Google Earth: Now Showing in AutoCAD Civil 3D (Page 18) AUGIWorld Magazine November/December 2007 - Google Earth: Now Showing in AutoCAD Civil 3D (Page 19) AUGIWorld Magazine November/December 2007 - Get Your Input Here (Page 20) AUGIWorld Magazine November/December 2007 - Get Your Input Here (Page 21) AUGIWorld Magazine November/December 2007 - Get Your Input Here (Page 22) AUGIWorld Magazine November/December 2007 - Get Your Input Here (Page 23) AUGIWorld Magazine November/December 2007 - A Good First Impression, Part 2 (Page 24) AUGIWorld Magazine November/December 2007 - A Good First Impression, Part 2 (Page 25) AUGIWorld Magazine November/December 2007 - A Good First Impression, Part 2 (Page 26) AUGIWorld Magazine November/December 2007 - A Good First Impression, Part 2 (Page 27) AUGIWorld Magazine November/December 2007 - Share and Share Alike (Page 28) AUGIWorld Magazine November/December 2007 - Share and Share Alike (Page 29) AUGIWorld Magazine November/December 2007 - Who's Using Revit MEP? (Page 30) AUGIWorld Magazine November/December 2007 - Who's Using Revit MEP? (Page 31) AUGIWorld Magazine November/December 2007 - Who's Using Revit MEP? (Page 32) AUGIWorld Magazine November/December 2007 - Who's Using Revit MEP? (Page 33) AUGIWorld Magazine November/December 2007 - Who's Using Revit MEP? (Page 34) AUGIWorld Magazine November/December 2007 - Who's Using Revit MEP? (Page 35) AUGIWorld Magazine November/December 2007 - Ready… Get Set… Properties! (Page 36) AUGIWorld Magazine November/December 2007 - Ready… Get Set… Properties! (Page 37) AUGIWorld Magazine November/December 2007 - Ready… Get Set… Properties! (Page 38) AUGIWorld Magazine November/December 2007 - Ready… Get Set… Properties! (Page 39) AUGIWorld Magazine November/December 2007 - Ready… Get Set… Properties! (Page 40) AUGIWorld Magazine November/December 2007 - Ready… Get Set… Properties! (Page 41) AUGIWorld Magazine November/December 2007 - Ready… Get Set… Properties! (Page 42) AUGIWorld Magazine November/December 2007 - Ready… Get Set… Properties! (Page 43) AUGIWorld Magazine November/December 2007 - On the Back Page: The Brazilian Model (Page 44) AUGIWorld Magazine November/December 2007 - On the Back Page: The Brazilian Model (Page Cover3) AUGIWorld Magazine November/December 2007 - On the Back Page: The Brazilian Model (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.