(defun c:sz()
(vl-load-com)
(setq old (getvar "cmdecho")
path (strcat (Vlax-Get (Vlax-Get-Acad-Object) 'Path) "\\Support")
files (vl-directory-files path "*.dwg" 1)
)
(setvar "cmdecho" 0)
(command "_undo" "be")
(initget "1 2 3")
(setq wjh (getkword "\n1/2/3<1>:"))
(if (= wjh nil) (setq wjh "1"))
(setq wjm (strcat path "\\" wjh ".dwg"))
(if (member (strcat wjh ".dwg") files)
(progn
(command "_insert" wjm '(0 0 0) 1 1 1)
(command "_zoom" "e")
)
(alert (strcat wjm ", 不存在!"))
)
(command "_undo" "e")
(setvar "cmdecho" old)
(princ)
)
(defun c:zm()
(vl-load-com)
(setq old (getvar "cmdecho")
path (strcat (Vlax-Get (Vlax-Get-Acad-Object) 'Path) "\\Support")
files (vl-directory-files path "*.dwg" 1)
)
(setvar "cmdecho" 0)
(command "_undo" "be")
(initget "a b c")
(setq wjh (getkword "\na/b/c:"))
(if (= wjh nil) (setq wjh "a"))
(setq wjm (strcat path "\\" wjh ".dwg"))
(if (member (strcat wjh ".dwg") files)
(progn
(command "_insert" wjm '(0 0 0) 1 1 1)
(command "_zoom" "e")
)
(alert (strcat wjm ", 不存在!"))
)
(command "_undo" "e")
(setvar "cmdecho" old)
(princ)
)
建议你上明经CAD论坛,上面可以搜到你要的代码。lisp论坛上高手很多,也很热心