好吧,我忍不住举个例子
- (defun c:test ( / *error* dcl dch )
- ;; Example by Lee Mac 2011 - www.lee-mac.com
-
- ;; Demonstrates how to remember a dialog screen
- ;; position for next use.
- ;; Requires accompanying file: test.dcl to be
- ;; in AutoCAD Support Path.
- (defun *error* ( msg )
- (if dch (unload_dialog dch))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ)
- )
- (cond
- (
- (not
- (and
- (setq dcl (findfile "test.dcl"))
- (< 0 (setq dch (load_dialog dcl)))
- )
- )
- (princ "\n** DCL File not found **")
- )
- (
- (not (new_dialog "test" dch "" (cond ( *screenpoint* ) ( '(-1 -1) ))))
-
- (setq dch (unload_dialog dch))
- (princ "\n** Dialog could not be Loaded **")
- )
- (t
- (action_tile "accept" "(setq *screenpoint* (done_dialog 1))")
- (start_dialog)
- (setq dch (unload_dialog dch))
- )
- )
- (princ)
- )
将以下内容另存为“测试”。支持路径中的dcl:
- test : dialog { label = "Test Dialog";
- spacer;
- : text { label = "Move me"; alignment = centered; }
- spacer;
- : button { key = "accept"; is_default = true; label = "I'm Done"; }
- }
在这种情况下,位置存储为全局变量,但可以更改代码以将屏幕位置转换为字符串,并在绘图会话之间将其存储在注册表中。
享受
李 |