我也分享另一种方法:
 - (defun c:L1 (/ *error* p1 p2)
- (defun *error* ( msg )
- (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
- (progn (princ (strcat "\n错误:" msg)) (setvar "CLAYER" "0"))
- )
- (princ)
- )
- (If (= (Tblsearch "layer" "新建") nil)
- (command "-layer" "n" "新建" "s" "新建" "")
- (command "-layer" "s" "新建" "")
- )
- (command "CECOLOR" "2") ;;;定义颜色
- (setq p1 (getpoint "\n 选择起点:"))
- (while (setq p2 (getpoint p1 "\n 选择下一点:"))(command "line" p1 p2 "")(setq p1 p2))
- (command "layer" "s" "0" "")
- )
|