这个我写了,我是用来打印计算书和图纸的。命令是pp
- (defun c:pp( / path poplst sel dcl_id dd tmp tmppath fn newcfg confirm show_list)
- (setq path (LJ:GetLoadPath))
- (setq tmp (vl-filename-mktemp nil nil ".dcl"))
- (setq fn (open tmp "w"))
- (write-line "changecfg:dialog {" fn)
- (write-line "label = "切换批量打印CFG 请配合ludaweb BPlot" ;" fn)
- (write-line " :text {" fn)
- (write-line " key = "title" ;" fn)
- (write-line " label = "选择CFG文件" ;" fn)
- (write-line " }" fn)
- (write-line " :popup_list {" fn)
- (write-line " key = "cfg" ;" fn)
- (write-line " }" fn)
- (write-line " spacer_1;" fn)
- (write-line " :row{" fn)
- (write-line " :button{ key = "swap"; label = "更新备份"; }" fn)
- (write-line " ok_cancel;" fn)
- (write-line " }" fn)
- (write-line "}" fn)
- (close fn)
- ;表显示
- (defun show_list (key newlist)
- (start_list key) ;
- (mapcar 'add_list newlist)
- (end_list)
- )
- (setq poplst (vl-directory-files path "*.cfg" 1))
- (setq sel "0")
- (setq dcl_id (load_dialog tmp))
- (new_dialog "changecfg" dcl_id)
- (show_list "cfg" poplst)
- (set_tile "cfg" sel);初始选择
- (setq confirm nil)
- (action_tile "cfg" "(setq sel $value)")
- (action_tile "swap" "(if confirm(done_dialog 2) (alert (setq confirm "你要替换原有设置,请再按一次确认操作")))")
- (action_tile "accept" "(done_dialog 1)")
- (setq dd (start_dialog))
- (cond ((= dd 1)
- (setq newcfg (strcat path (nth (atoi sel) poplst)))
- (setq tmppath (vl-filename-directory tmp))
- (vl-file-delete (strcat tmppath "\\batchplot.cfg"))
- (vl-file-copy newcfg (strcat tmppath "\\batchplot.cfg"))
- )
- ((= dd 2)
- (setq newcfg (strcat path (nth (atoi sel) poplst)))
- (setq tmppath (vl-filename-directory tmp))
- (vl-file-delete newcfg)
- (vl-file-copy (strcat tmppath "\\batchplot.cfg") newcfg)
- )
- )
- (vl-file-delete tmp)
- (princ)
- )
- (defun LJ:GetLoadPath ( / path)
- ;(princ "\n即将获取加载目录……")
- (if (wcmatch (setq path (getvar "lastprompt")) "*(LOAD "*")")
- (progn
- (setq path (cadr (parse path """)))
- (while (vl-string-search "/" path)
- (setq path (vl-string-subst "\" "/" path))
- )
- ;(alert (strcat "\n拖入方式加载目录:" path))
- )
- (progn
- (setq path (vl-registry-read (strcat "HKEY_CURRENT_USER\" (vlax-product-key) "\\Profiles\" (getvar "CPROFILE") "\\Dialogs\\Appload") "MainDialog"))
- ;(alert (strcat "\nAPPLOAD方式加载目录:" path))
- )
- )
- )
|