Edit Box
| Function Syntax | (LM:EditBox <string>) |
| Current Version | 1.0 |
| Arguments | ||
|---|---|---|
| Symbol | Type | Description |
| string | String | Initial value to display ("" for none) |
| Returns | ||
| Type | Description | |
| String | Edit box contents if user pressed OK, else nil | |
Program Description
This very simple function utilises a predefined AutoCAD dialog definition to display an interface allowing the user to input a text string.
This approach avoids the need to include an accompanying DCL file with the calling program, or write a temporary dialog definition file to the user's computer.
Select all
;;----------------------=={ Edit Box }==----------------------;; ;; ;; ;; Displays a DCL Edit Box to obtain a string from the user ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; string - initial value to display ("" for none) ;; ;;------------------------------------------------------------;; ;; Returns: Edit box contents if user pressed OK, else nil ;; ;;------------------------------------------------------------;; (defun LM:EditBox ( string / id ) (and (< 0 (setq id (load_dialog "ACAD"))) (new_dialog "acad_txtedit" id) (set_tile "text_edit" string) (action_tile "text_edit" "(setq string $value)") (if (zerop (start_dialog)) (setq string nil)) ) (if (< 0 id) (unload_dialog id)) string )
Example Function Call
The following function call will display the dialog as shown in the graphic below.
(LM:EditBox "Lee Mac")
Example Program
This short program uses the above subfunction to allow the user to edit a selected text or attribute object.
Select all
(defun c:qe ( / en st ) (if (and (setq en (car (nentsel))) (wcmatch (cdr (assoc 0 (setq en (entget en)))) "TEXT,ATTRIB") (setq st (LM:EditBox (cdr (assoc 1 en)))) ) (entupd (cdr (assoc -1 (entmod (list (assoc -1 en) (cons 1 st)))))) ) (princ) )
