- (defun c:test (/ dcl_id dclfn f datalst line data)
- (vl-load-com)
- (setq dclfn (vl-filename-mktemp "test.dcl"))
- (setq f (open dclfn "w"))
- (mapcar '(lambda (x) (write-line x f))
- '("Test: dialog { label = "选择数据";"
- ":list_box { key = "data"; width = 20; height = 10;}"
- "ok_cancel;"
- "}"
- )
- )
- (close f)
- (setq dcl_id (load_dialog dclfn))
- (if (null (new_dialog "Test" dcl_id))
- (exit)
- )
- (setq f (open (findfile "w1.dat") "r"))
- (setq datalst nil)
- (while (setq line (read-line f))
- (setq datalst (cons line datalst))
- )
- (close f)
- (setq datalst (reverse datalst))
- (start_list "data")
- (mapcar 'add_list datalst)
- (end_list)
- (action_tile
- "data"
- "(if (= $reason 4)
- (progn
- (setq data (nth (atoi $value) datalst))
- (done_dialog 1)
- )
- )"
- )
- (action_tile
- "accept"
- "(setq data (nth (atoi (get_tile "data")) datalst))(done_dialog 1)"
- )
- (if (= (start_dialog) 1)
- (AddTexts (read data))
- )
- (unload_dialog dcl_id)
- (vl-file-delete dclfn)
- (princ)
- )
- ;;;;----------------------------------
- (defun AddTexts (txtlst / mspace ptlst)
- (setq mspace (vla-get-modelspace
- (vla-get-activedocument (vlax-get-acad-object))
- )
- )
- (setq ptlst
- (mapcar 'vlax-3d-point '((0 0 0) (0 20 0) (0 40 0) (0 60 0)))
- )
- (mapcar '(lambda (pt txt) (vla-addtext mspace txt pt 5.0))
- ptlst
- txtlst
- )
- (vlax-release-object mspace)
- )
|