lisp编程 在打开的CAD图中,插入另一已画好的cad图

2024-12-20 18:56:30
推荐回答(2个)
回答1:

(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)
)

回答2:

建议你上明经CAD论坛,上面可以搜到你要的代码。lisp论坛上高手很多,也很热心