Values can be stored and retrieved from AutoLISP variables while a drawing remains open.
- At the AutoCAD Command prompt or in an AutoLISP program, enter an AutoLISP statement that uses the setq function and press Enter.
- Enter the name of the variable you assigned a value to and prefix it with an ! (exclamation point) to return the value assigned to the variable and press Enter.
Example
- In the AutoCAD drawing environment, create or open two new drawings.
- Do one of the following:
- At the AutoCAD Command prompt, enter (setq draw1foo "I am drawing 1") and press Enter.
Returns:
"I am drawing 1"
- Activate the second drawing by clicking in the window's title bar.
- At the AutoCAD Command prompt, enter !draw1foo and press Enter.
Returns:
nil
The variable is nil because it has not been set in this document’s.
- At the AutoCAD Command prompt, enter (setq draw2foo "I too am a drawing, but number 2") and press Enter.
Returns:
"I too am a drawing, but number 2"
- Activate the previous drawing.
- At the AutoCAD Command prompt, enter !draw1foo and press Enter.
Returns:
"I am drawing 1"
- At the AutoCAD Command prompt, enter !draw2foo and press Enter.
Returns:
nil
The draw1foo variable contains the value you set in Step 3, but draw2foo is nil because you did not set it to a value in the current document; you set a different variable of the same name in the second drawing's namespace.