Learn how to collect numbers, strings, points, and object selections using AutoLISPβs built-in input functions.
π What Youβll Learn
By the end of this lesson, youβll be able to:
Prompt the user for integers, real numbers, strings, and coordinates
Use initget to control input behavior
Select objects interactively with entsel
Validate and handle input effectively in custom commands
π§ Why It Matters
User input is the gateway to interactive automation in AutoCAD. By mastering these functions, you can build routines that adapt to user decisions, geometry selections, and numeric dataβall essential for custom workflows.
π οΈ Tools Youβll Use
Function
Purpose
getint
Get an integer from the user
getreal
Get a real (decimal) number
getstring
Get text input from the user
getpoint
Let the user click or enter a coordinate
initget
Add input constraints (e.g., keywords, no NULL)
entsel
Prompt user to select an object
π§ Lesson Structure
1οΈβ£ Getting Numbers and Text
Use these functions to collect basic input from the user:
(setq age (getint "\nEnter your age: ")) (setq price (getreal "\nEnter price: ")) (setq name (getstring "\nEnter your name: "))
Function
Expected Input
Example Input
Returns
getint
Whole number
45
45
getreal
Decimal number
129.99
129.99
getstring
Text string
John
"John"
πΉ Tip: Use (getstring T ...) to allow spaces in string input.
2οΈβ£ Getting Points from User
You can collect coordinate input using getpoint:
(setq pt (getpoint "\nPick a point: "))
Input Type
Example Result
Mouse click
(100.0 200.0 0.0)
Typed value
50,100 becomes (50.0 100.0 0.0)
Use points in drawing commands like LINE, CIRCLE, or for geometry logic.
3οΈβ£ Controlling Input with initget
Use initget to filter or extend input:
(initget 1 "Yes No") (setq response (getkword "\nDo you want to continue? [Yes/No]: "))
ode
Description
(initget 1)
Disallows null input (user must respond)
(initget "Yes No")
Accepts only the listed keywords
(getkword ...)
Collects a keyword from the user
π¨ Always call initgetbefore the input function!
4οΈβ£ Selecting Objects with entsel
Use entsel to let the user click an entity in the drawing:
(setq sel (entsel "\nSelect an object: "))
User hit escape or didnβt click
You can pass the result to entget to retrieve object data.