robbt,
我重写了您的代码,以演示如何完成任务,希望您可以从我的代码中学习。
- (defun c:tree ( / blk id scl ts )
- (cond
- ( (or
- (<= (setq id (load_dialog "tree.dcl")) 0)
- (not (new_dialog "tree" id))
- )
- (princ "\nDialog could not be Loaded.")
- )
- ( t
- (set_tile (cond (*tree*) ((setq *tree* "pine"))) "1")
- (set_tile "scl" (cond (*scale*) ((setq *scale* "12.0"))))
- (set_tile "txt" (cond (*text* ) ((setq *text* "12""))))
- (set_tile "ts" (cond (*style*) ((setq *style* "Standard"))))
- (foreach tile '("pine" "oak" "juniper")
- (action_tile tile "(setq *tree* $key)")
- )
- (action_tile "scl" "(setq *scale* $value)")
- (action_tile "txt" "(setq *text* $value)")
- (action_tile "ts" "(setq *style* $value)")
- (action_tile "accept"
- (vl-prin1-to-string
- '(cond
- ( (null (setq scl (distof *scale*)))
- (alert "Scale must be numerical!")
- (mode_tile "scl" 2)
- )
- ( (null (tblsearch "STYLE" *style*))
- (alert "TextStyle not found!")
- (mode_tile "ts" 2)
- )
- ( (done_dialog 1))
- )
- )
- )
- (if (= 1 (start_dialog))
- (if
- (or
- (tblsearch "BLOCK" (setq blk *tree*))
- (setq blk (findfile (strcat *tree* ".dwg")))
- )
- (command
- "_.-insert" blk "_S" scl "_R" 0.0 pause
- "_.text" "_S" ts pause "" *text*
- )
- (princ (strcat "\n" *tree* ".dwg not found."))
- )
- )
- )
- )
- (if (< 0 id) (unload_dialog id))
- (princ)
- )
|