看看这样是否可行
- (defun err(msg)
- (princ msg)
- (setvar "osmode" os)
- (setvar "cmdecho" cmd)
- (setq *error* errtmp)
- (princ)
- )
- (defun c:test( / pt1 pt2 pt3 ptCenter)
- (setq os (getvar "osmode"))
- (setq cmd (getvar "cmdecho"))
- (setq errtmp *error*)
- (setq *error* err)
- (setq pt1 (getpoint "\n输入第一点:"))
- (setq pt2 (getpoint "\n输入第二点:"))
- (setvar "osmode" 0)
- (setvar "cmdecho" 0)
- (setq pt1 (trans pt1 1 0))
- (setq pt2 (trans pt2 1 0))
- (command "_.ucs" "")
- (setq ptCenter (list (/ (+ (car pt1) (car pt2)) 2)
- (/ (+ (cadr pt1) (cadr pt2)) 2)
- 0.0))
- (setq ang (angle pt1 pt2))
- (if (> ang pi)
- (setq ang (- ang pi))
- )
- (cond
- ((equal (/ pi 2) ang 0.00001) (setq pt3 nil))
- (t (setq pt3 (polar ptCenter (- ang) (/ (distance pt1 pt2) 2))))
- )
- (command "_.line" pt1 pt2 "")
- (if pt3
- (command "_.line" ptCenter pt3 "")
- )
- (command "_.ucs" "p")
- (setvar "osmode" os)
- (setvar "cmdecho" cmd)
- (setq *error* errtmp)
- (princ)
- )
|