AutoLISP offers a set of functions that enable a pause to allow input for just this purpose. The functions are characterised by Get prefix.
Here are
Function names and
Types of user input:
Getint: (getint string) It returns an integer value from the prompt line. If a real number is supplied it returns only the integer part.
(if (= aval nil) (setq aval 7))
(princ "Enter a value ... <") (princ aval) (princ "> ")
(setq avalue (getint))
(if (not avalue)
(setq aval 7)
(setq aval avalue)
)
Getreal: (getreal string) It returns a real value from the prompt line. If you supply an integer, it is returned converted into a real number.
(if (= aval nil) (setq aval 7.5))
(princ "Enter a value ... <") (princ aval) (princ "> ")
(setq avalue (getreal))
(if (not avalue)
(setq aval 7.5)
(setq aval zvalue)
)
Getstring: (getstring number string) It returns a string from the prompt line. If number is non-nil expression or symbol, it will allow spaces. You can enter up to 132 characters. (Generally t is used as non-nil expression which evaluates to true)
(if (= strval nil) (setq strval "acad"))
(princ "Enter a Name ... <") (princ strval) (princ "> ")
(setq strvalue (getstring t))
(if (= strvalue "")
(setq strval "acad")
(setq strval strvalue)
)
Getkword: (getkword string) It returns a predefined key word or its abbreviation from the prompt line. It is used with (initget) function.
Getangle: (getangle p1 string) It returns an angle value (in the current angle format) from the prompt line or based on selected points on the screen. You must supply one or two optional arguments to getangle. If first point is defined it can be first argument. Program uses that point for rubber banding to select second point. If it is not provided program asks to select 2 points. Second optional argument is a string that is displayed at command prompt.
Getorient: (getorient p1 string) It returns an angle value (in the default angle format) from the prompt line or based on selected points on the screen. You must supply one or two optional arguments to getorient. If first point is defined it can be first argument. Program uses that point for rubber banding to select second point. If it is not provided program asks to select 2 points. Second optional argument is a string that is displayed at command prompt.
Getdist: (getdist p1 string) It returns a real or integer value (of distance) from the prompt line or determined by selecting points on the screen. You must supply one or two optional arguments to getdist. If first point is defined it can be first argument. Program uses that point for rubber banding to select distance. If it is not provided program asks to select 2 points. Second optional argument is a string that is displayed at command prompt. It accepts both cursor input (one or two points) or keyboard input (real number).
Getpoint: (getpoint p1 string) It returns a point value from the prompt line or selected from the screen. You must supply one or two optional arguments to getpoint. If first point is defined it can be first argument. Program uses that point for rubber banding to select second point. If it is not provided program asks to select a point.
Getcorner: (getcorner p1 string) It returns a point value (the opposite corner of a box) from the prompt line or selected from the screen. You must supply one or two optional arguments to getcorner. First point is defined as first argument. Program uses that point for rubber banding to select second point. Program asks to select second corner.
Optional Arguments: You may supply one or more arguments to these functions. These can be omitted too. If these are supplied, these should be in order.
(getdist p1 string): The starting point p1 should be predefined, and string is displayed. There is rubber banding from first point. You need to select second point to get distance.
(getdist string): The starting point p1 is not defined, and string is displayed. You need to select first point. There is rubber banding from first point and then you are asked to select second point to get distance.
(getdist): The starting point p1 is not defined, and no string is displayed. You need to select first point. There is rubber banding from first point and then you are asked to select second point to get distance.
Initget: function establishes the keywords Yes/No. (initget “Yes/No”). You can then use (getkword “Yes/No”). If user enters either of capitalised letter, it is accepted as string. Any other string will force it to try again till either of the alphabet (capital or small) is entered. Initget can also be used to control user input with a bit code as argument. For similar options, capitalize two letters (getkword “LAyer/LInetype”).
Code Meaning
Null input not allowed
Zero value not allowed
4 Negative value not allowed
16 Do not check limits for point values
32 Return 3D point, rather than 2D point
Use dashed lines for rubber banding and windows
Functions and
Initget bit code honored:
getint 1,2,4
getreal 1,2,4
getdist 1,2,4,16,32
getangle 1,2,32
getorient 1,2,32
getpoint 1,8,16,32
getcorner 1,8,16,32
getkword 1
getstring none
Selection Set: You can create a set of objects. ssget is abbreviation for Selection Set Get. ssget allows you to select entities to be processed by program. It returns set of entities as a value.
. The value is not important as selection set is tied to a variable. (ssget) will prompt “select object”. (ssget “P”) will select last selection set. (ssget “L”) will select last entity drawn. (ssget “W”) will select objects by Window. (ssget “C”) will select objects by Crossing Window. (ssget “W” p1 p2) will select objects by Window formed by p1 p2. (ssget “C” p1 p2) will select objects by Crossing Window formed by p1 p2.
You should create 6 selection set at a time. Once used, these should be set to nil.