(vmon)
  (defun dir(aa)
  (* pi (/ aa 180.0))
  )
(defun lsw1()
;   ver 4.5
      (setq a 1)
   (setq g2 0)
   (setq g3 0)
           (while (<= a 4)
    (setq g2 (1+ g2))
    (setq g3 (1+ g3))
           (command "layer" "m" g2 "c" g3 g2 /r)
     (setq a (1+ a))
   )
                (command "layer" "s" "4" /r)
   (command "load" "a:lsw")
  (command "aperture" "6" /r)
  (command "osnap" "off")
; (setq m1 (getstring "\n请输入文件名:"))
  (setq m1 "dqb2.map")
; (setq m1 (strcat m1 ".out"))
  (setq fs (open m1 "r"))
;
  (setq a (read-line fs) b (read a))
  (setq xs (car b))
;
;  (setq wd (getstring "\n问题类型(稳定W非稳定F)?"))
  (setq a (read-line fs) b (read a))
  (setq s1 (car b))
  (setq wd "f")
  (IF (= s1 0)
  (setq wd "w"))
  (setq a (read-line fs) b (read a))
  (setq s1 (car b))
  (setq c 1)
  (while (<= c s1)
  (setq a (read-line fs) b (read a))
  (setq s2 (list (car b) (cadr b)))
  (setq s3 (list (nth 2 b) (nth 3 b)))
  (command "pline" s2 "w" "0.04" "0.04" s3 /r)
  (setq c (1+ c))
 )
   (command "zoom" "e" /r)
;
  (IF (OR (= wd "f") (= wd "F"))
  (setq wd "f"))
  (IF (OR (= wd "w") (= wd "W"))
  (setq wd "w"))
   (if (= wd "f")
  (setq a (read-line fs) b (read a)))
   (if (= wd "f")
  (setq bb b))
   (if (= wd "f")
  (setq bs b))
;
  (setq a (read-line fs) b (read a))
  (setq s1 (car b))
  (setq ss (cadr b))
  (setq s11 1000.0)
  (setq s10 0.0)
  (setq s02 1000.0)
  (setq s01 0.0)
  (setq c 1)
  (while (<= c s1)
  (setq a (read-line fs) b (read a))
  (setq s2 (list (car b) (cadr b)))
  (setq s3 (list (nth 2 b) (nth 3 b)))
  (setq s4 (list (nth 4 b) (nth 5 b)))
  (setq s5 (list (nth 6 b) (nth 7 b)))
  (setq s21 (car s2))
  (setq s31 (car s3))
  (setq s41 (car s4))
  (setq s51 (car s5))
  (setq s22 (cadr s2))
  (setq s32 (cadr s3))
  (setq s42 (cadr s4))
  (setq s52 (cadr s5))
  (if (> s10 s21)
  (setq s10 s10) (setq s10 s21))
  (if (> s10 s31)
  (setq s10 s10) (setq s10 s31))
  (if (> s10 s41)
  (setq s10 s10) (setq s10 s41))
  (if (> s10 s51)
  (setq s10 s10) (setq s10 s51))
  (if (< s11 s21)
  (setq s11 s11) (setq s11 s21))
  (if (< s11 s31)
  (setq s11 s11) (setq s11 s31))
  (if (< s11 s41)
  (setq s11 s11) (setq s11 s41))
  (if (< s11 s51)
  (setq s11 s11) (setq s11 s51))
  (if (> s01 s22)
  (setq s01 s01) (setq s01 s22))
  (if (= s01 s22)
  (setq m6 s21))
  (if (> s01 s32)
  (setq s01 s01) (setq s01 s32))
  (if (= s01 s32)
  (setq m6 s31))
  (if (> s01 s42)
  (setq s01 s01) (setq s01 s42))
  (if (= s01 s42)
  (setq m6 s41))
  (if (> s01 s52)
  (setq s01 s01) (setq s01 s52))
  (if (= s01 s52)
  (setq m6 s51))
  (if (< s02 s22)
  (setq s02 s02) (setq s02 s22))
  (if (< s02 s32)
  (setq s02 s02) (setq s02 s32))
  (if (< s02 s42)
  (setq s02 s02) (setq s02 s42))
  (if (< s02 s52)
  (setq s02 s02) (setq s02 s52))
;
  (setq c (1+ c))
 )
   (command "zoom" "0.6x" /r)
;
  (setq m1 (- s10 s11))
  (setq m2 (- s01 s02))
;
  (setq k2 s11)
  (setq k2 (fix k2))
  (setq k5 k2)
  (setq k2 (itoa k2))
  (setq k3 (strlen k2))
  (if (< k3 2)
  (setq k4 0.0)
  )
  (setq t 1)
  (if (= k3 2)
  (while (<= t 10)
  (if (<= k5 50.0)
  (setq k4 0.0)
  (setq k4 50.0))
  (setq t 20)
  )
  )
;
  (setq t 1)
 (if (> k3 2)
  (while (<= t 10)
 (setq k6 (- k3 2))
 (setq k7 (substr k2 1 k6))
  (setq k8 k7)
  (setq k7 (strcat k7 "00"))
  (setq k7 (atof k7))
  (setq k7 (- k5 k7))
  (if (<= k7 50.0)
  (setq k9 "00")
  (setq k9 "50"))
  (setq k4 (strcat k8 k9))
  (setq k4 (atoi k4))
  (setq t 20)
  )
)
;
  (if (< s02 10)
  (setq l1 s02)
  (setq l1 (- s02 10)))
  (setq l1 (fix l1))
  (setq l1 (itoa l1))
  (setq l2 (strlen l1))
 (if (= l2 1)
 (setq l4 1)
  (setq l4 (- l2 1)))
  (setq l3 (substr l1 1 l4))
  (setq l3 (strcat l3 "0"))
  (setq l3 (atoi l3))
  (if (= l2 1)
  (setq l3 0.0) (setq l3 l3))
  (setq mm 5.0)
  (setq mm1 7.0)
  (setq m1 (/ m1 50.0))
  (setq m2 (/ m2 10.0))
  (setq m1 (fix m1))
  (setq m2 (fix m2))
   (setq m5 s01)
   (setq m7 (rtos m5 2 2))
   (setq m8 (* mm1 6.2))
   (setq m8 (- m6 m8))
   (setq m9 (+ m5 3.0))
   (setq m10 (+ m8 1.5))
   (setq m11 (- m8 1.5))
  (command "pline" (list m6 m5) "w" "0.0" "" (list m8 m5) (list m11 m9))
  (command (list m10 m9) (list m8 m5) "")
  (setq m8 (- m6 mm1))
   (setq ll m6)
; (setq m8 (- m8 (/ mm1 1.2)))
  (setq m8 (+ m10 2.0))
  (setq m5 (+ m5 1.0))
  (command "text" (list m8 m5) mm "0.0" m7)
;
                (command "layer" "s" "3" /r)
  (if (= wd "f")
  (setq g1 (* mm1 8.5))
   (setq g1 (* mm1 8.0)))
   (setq g2 (+ s01 g1))
  (setq s1 (- s10 s11))
  (setq s1 (/ s1 2.0))
  (setq s1 (+ s11 s1))
  (setq m6 s1)
   (setq g3 (+ m6 g1))
   (setq g4 (- m6 g1))
   (setq g5 (+ g2 1.0))
  (setq g6 (+ g4 1.0))
  (setq b1 m6)
  (setq b2 g2)
   (command "pline" (list g3 g2) "w" "0.5" "" (list g4 g2) "")
  (if (= wd "f")
  (command "shape" "a07" (list g6 g5) mm1 "0.0")
   (command "shape" "a06" (list g6 g5) mm1 "0.0"))
   (setq g1 (+ g3 mm1))
   (setq g2 (- g2 mm1))
   (setq g3 (* mm1 2.1))
   (setq g4 (+ g1 g3))
   (command "shape" "a02" (list g1 g2) mm "0.0")
   (setq g5 "1:100")
   (command "text" (list g4 g2) "4.2" "0.0" g5)
   (setq g2 (- g2 mm1))
   (command "shape" "a01" (list g1 g2) mm "0.0")
  (command "shape" "a12" (list g4 g2) "4.2" "0.0")
;
;
  (setq s11 k4)
  (setq s02 (- s02 s02))
  (setq s01 (+ s01 30.0))
  (setq k1 s10)
  (setq s10 (+ s10 35.0))
   (setq s10 (fix s10))
   (setq s11 (fix s11))
   (setq s01 (fix s01))
   (setq s02 (fix s02))
  (command "pline" (list s10 l3) "w" "0.0" "" (list s11 l3) (list s11 s01) /r)
  (setq x1 s11)
  (setq x2 s10)
  (setq y1 l3)
  (setq y2 s01)
  (setq s1 (- s11 1.0))
  (setq s2 (+ s11 1.0))
  (setq s3 (- s01 1.0))
   (setq s4 (+ s11 1.5))
  (setq b3 s4)
  (setq b4 s3)
   (command "text" (list s4 s3) mm1 "0.0" "Y")
  (command "pline" (list s1 s3) "w" "0.05" "" (list s11 s01) (list s2 s3) /r)
  (setq s1 (- s10 1.0))
  (setq s2 (+ l3 1.0))
  (setq s3 (- l3 1.0))
   (setq s4 (- l3 mm1))
  (command "text" (list s10 s4) mm1 "0.0" "X")
  (command "pline" (list s1 s2) "w" "0.05" "" (list s10 l3) (list s1 s3) /r)
   (setq s1 (- l3 mm1))
  (setq s2 (rtos s11 2 1))
   (setq s1 (- s11 mm))
  (setq s2 (rtos s02 2 1))
   (setq m3 (+ l3 0.5))
   (setq m4 (- l3 0.5))
  (setq m7 (- m4 mm1))
  (setq s12 s11)
  (setq m1 (1+ m1))
  (setq g1 (/ m1 2))
  (setq g1 (fix g1))
    (setq g1 (+ g1 1))
   (setq n 1)
  (while (<= n m1)
  (setq s11 (+ s11 50.0))
  (if (<= s11 k1)
  (command "pline" (list s11 m3) "w" "0.05" "" (list s11 m4) ""))
  (setq n (1+ n))
  (setq m6 (list s11 m7))
  (setq m8 (rtos s11 2 1))
  (setq s11 (+ s11 0.0))
    (setq nb (- mm (/ mm 3.0)))
  (if (<= s11 k1)
  (command "text" "c" m6 nb "0.0" m8) (setq n (1+ n)))
   )
;
  (setq s11 s12)
   (setq m3 (+ s11 0.5))
   (setq m4 (- s11 0.5))
  (setq m7 (- m4 mm1))
   (setq m8 (/ mm1 2.0))
   (setq m7 (- m7 m8))
  (setq m2 (+ m2 2))
   (setq n 1)
  (setq s02 l3)
  (while (<= n m2)
  (setq s02 (+ s02 10.0))
  (command "pline" (list m3 s02) "w" "0.05" "" (list m4 s02) "")
  (setq a 1)
  (if (= n m2)
  (while (<= a 10)
  (setq m3 (+ m3 5.0))
  (if (= wd "f")
  (command "shape" "a13" (list m3 s02) nb "0.0"))
  (setq a 20)
  )
  )
;
  (setq n (1+ n))
  (setq m6 (list m7 s02))
  (setq m8 (rtos s02 2 1))
  (setq s02 (+ s02 0.0))
  (command "text" "c" m6 nb "0.0" m8)
   )
;
   ;
   )
 ;
(defun lsw2()
  (setq c 1)
  (if (= wd "f")
   (while (<= c 20)
  (setq s1 (car bb))
  (setq s2 (cadr bb))
  (setq b5 s2)
  (setq s1 (rtos s1 2 1))
  (setq s2 (rtos s2 2 1))
  (setq s1 (strcat "(" s1 "~~"))
  (setq s1 (strcat s1 s2 ")"))
  (setq s2 (- b1 (* nb 3.5)))
  (setq s3 (- b1 (* nb 1.0)))
  (setq s4 (- b2 (* nb 3.0)))
  (command "shape" "a08" (list s2 s4) nb "0.0")
  (command "text" (list s3 s4) nb "0.0" s1)
  (setq a (read-line fs) b (read a))
  (setq s1 (car b))
   (setq s1 (rtos s1 2 1))
  (setq s2 (- b1 (* nb 2.5)))
  (setq s3 (+ b1 (* nb 3.0)))
  (setq s4 (- s4 (* nb 2.0)))
  (command "shape" "a09" (list s2 s4) nb "0.0")
  (command "text" (list b1 s4) nb "0.0" s1)
  (command "shape" "a10" (list s3 s4) nb "0.0")
  (setq a (read-line fs) b (read a))
  (setq s1 (car b))
  (setq d 1)
  (while (<= d s1)
  (setq a (read-line fs) b (read a))
   (setq s3 (car b))
   (setq s4 (cadr b))
   (setq s3 (+ b3 (* s3 2.0)))
  (setq s2 (list s3 s4))
  (if (= d s1)
  (setq s5 s2))
  (if (= d 1)
  (command "pline" s2))
   (if (/= d 1)
  (command s2))
  (setq d (1+ d))
  )
  (command /r)
  (setq s6 (car s5))
  (setq s7 (cadr s5))
  (setq s6 (+ s6 mm))
  (command "pline" (list b3 s7) "w" "0.05" "" (list s6 s7) "")
  (setq s6 (+ s6 1.0))
  (setq s7 (- s7 1.0))
  (command "text" (list s6 s7) nb "0.0" "t")
  (setq m1 (- s6 b3))
  (setq m1 (/ m1 10.0))
  (setq m1 (fix m1))
  (setq s1 (- s7 1.0))
  (setq s2 (+ s7 1.0))
  (setq s3 0)
  (setq s4 (- s7 mm))
  (setq s5 (- nb (/ nb 3.0)))
  (setq k1 1)
  (while (<= k1 m1)
  (setq b3 (+ b3 10.0))
  (setq s3 (+ s3 5))
  (setq s6 s3)
  (setq s6 (itoa s6))
   (command "pline" (list b3 s1) "w" "0.05" "" (list b3 s2) "")
   (command "text" "c" (list b3 s4) s5 "0.0" s6)
   (setq k1 (1+ k1))
  )
;
  (setq c 30))
 )
;
                (command "layer" "s" "2" /r)
    (setq a1 1)
  (if (= wd "f")
   (while (<= a1 3)
   (setq a (read-line fs) b (read a))
   (setq s1 (car b))
   (setq c 1)
  (setq s3 (/ s1 2))
  (setq s3 (fix s3))
  (if (<= s1 9)
 (setq s3 (- s1 2))
  (setq s3 (+ s3 4)))
   (while (<= c s1)
    (setq a (read-line fs) b (read a))
  (if (= c s1)
  (setq s2 /r))
    (setq s2 (list (car b) (cadr b)))
  (if (= c 1)
    (command "pline" s2))
   (if (= c s3)
  (setq s3 s2))
 (if (/= c 1)
   (command s2))
    (setq c (1+ c))
   )
  (command "")
   (setq a1 7)
  )
  )
;
;
   (setq a (read-line fs) b (read a))
   (setq s1 (car b))
   (setq c 1)
  (if (= wd "w")
  (SETQ S1 (- S1 1)))
  (setq s3 (/ s1 2))
  (setq s3 (fix s3))
  (if (<= s1 9)
 (setq s3 (- s1 1))
  (setq s3 (+ s3 4)))
   (while (<= c s1)
    (setq a (read-line fs) b (read a))
    (setq s2 (list (car b) (cadr b)))
  (if (= c 1)
    (command "pline" s2))
   (if (= c 1)
   (setq l1 s2))
   (if (= c s3)
  (setq s3 s2))
   (if (= c s1)
  (setq g1 s2))
 (if (/= c 1)
   (command s2))
    (setq c (1+ c))
   )
  (command "")
  (setq c 1)
  (if (= wd "w")
  (while (<= c 20)
    (setq a (read-line fs) b (read a))
  (setq g2 (list (car b) (cadr b)))
  (command "pline" g1 "w" "0.05" "" g2 /r)
  (setq g5 (getstring "\n对加入最后一点满意吗?(Y/N):"))
  (IF (OR (= g5 "Y") (= g5 "y"))
  (setq g5 "y"))
  (if (or (= g5 "n") (= g5 "N"))
  (setq g5 "n"))
  (if (= g5 "n")
 (command "u"))
  (if (/= g5 "n")
  (setq s2 g2)
 )
  (setq c 30)
 ))
;
;
  (setq s4 (car s3))
  (setq s5 (cadr s3))
  (setq s6 (* mm1 4.0))
  (setq s7 (* mm1 3.0))
  (setq s8 (+ s4 s7))
  (setq s9 (+ s5 s6))
  (setq s4 (+ s8 1.0))
  (setq s5 (+ s9 1.0))
  (if (= wd "f")
  (command "shape" "a11" (list s4 s5) mm "0.0")
  (command "shape" "a03" (list s4 s5) mm "0.0"))
  (if (= wd "f")
  (setq s7 (* mm1 4.1))
  (setq s7 (* mm1 2.6)))
  (setq s4 (+ s8 s7))
  (command "pline" s3 "w" "0.05" "" (list s8 s9) (list s4 s9) "")
   (setq s3 (car s2))
   (setq s4 (cadr s2))
   (setq s5 (* mm1 5.0))
   (setq s11 (rtos s4 2 2))
   (setq s6 (+ s4 1.0))
   (setq s7 (+ s3 mm1))
    (setq s7 (+ s7 3.0))
   (setq s3 (+ s3 s5))
   (setq s8 (+ s7 1.5))
   (setq s9 (- s7 1.5))
   (setq s10 (+ s4 3.0))
  (if (= wd "w")
   (command "pline"  s2 "w" "0.05" "" (list s7 s4) (list s8 s10)))
  (if (= wd "w")
   (command (list s9 s10) (list s7 s4) (list s3 s4) ""))
  (setq s7 (+ s8 2.0))
  (if (= wd "w")
   (command "text" (list s7 s6) mm "0.0" s11))
;
   (setq t 1)
  (if (= wd "f")
  (while (<= t 20)
   (setq s3 (car l1))
   (setq s4 (cadr l1))
   (setq s5 (* mm1 4.7))
   (setq s11 (rtos s4 2 2))
   (setq s6 (+ s4 1.0))
   (setq s7 (- s3 s5))
   (setq s8 (+ s7 1.5))
   (setq s9 (- s7 1.5))
   (setq s10 (+ s4 3.0))
   (command "pline"  l1 "w" "0.05" "" (list s7 s4) (list s8 s10))
   (command (list s9 s10) (list s7 s4) "")
  (setq s7 (+ s8 2.0))
   (command "text" (list s7 s6) mm "0.0" s11)
   (setq t 30)
   )
 )
;
  )
;
  (defun lsw3()
;
                (command "layer" "s" "1" /r)
  (setq c 1)
  (while (<= c 20)
  (command "osnap" "off" /r)
  (setq d 1)
  (setq a (read-line fs) b (read a))
  (setq s2 (car b))
   (setq l2 s2)
  (setq s2 (itoa s2))
  (setq cc s2)
;
  (setq s2 (strcat s2 "%"))
  (setq a (read-line fs) b (read a))
   (setq s3 (car b))
   (setq s3 (- s3 1))
   (setq s6 (/ s3 2))
   (setq s6 (+ s6 1.5))
  (SETQ S6 (FIX S6))
  (if (= wd "f")
  (setq m2 s6)
   (setq m2 (+ s6 1)))
  (while (<= d s3)
  (setq a (read-line fs) b (read a))
  (setq s5 (list (car b) (cadr b)))
  (setq cc1 1)
  (if (= wd "w")
  (while (<= cc1 10)
  (setq t 1)
  (if (= c 3)
  (while (<= t 20)
  (if (= d m2)
   (setq m1 s5)
  )
  (setq t 39)
;
)
 )
  (setq cc1 20)
  )
  )
;
  (setq cc1 1)
  (if (= wd "f")
  (while (<= cc1 10)
  (setq cc2 1)
  (if (= cc "20")
   (while (<= cc2 10)
    (setq t 1)
  (if (= d m2)
   (setq m1 s5))
  (setq cc2 20)
  )
  )
;
  (setq cc1 20)
  )
  )
;
  (setq cc1 1)
  (if (= wd "f")
  (while (<= cc1 10)
  (setq cc2 1)
  (if (= cc "25")
   (while (<= cc2 10)
    (setq t 1)
  (if (= d m2)
   (setq m1 s5))
  (setq cc2 20)
  )
  )
;
  (setq cc1 20)
  )
  )
   (if (= d 1)
  (setq c1 s5))
  (if (= d s3)
  (setq c2 s5))
  (if (= d 1)
  (command "pline" s5))
  (if (/= d 1)
  (command s5))
  (if (= d s6)
  (setq s8 (angle s4 s5)))
  (if (= d s6)
  (setq s8 (angtos s8 0 2)))
   (if (= d s6)
   (setq s7 (- (car b) 1.0)))
   (if (= d s6)
   (setq s7 (list s7 (cadr b))))
  (setq s4 s5)
  (setq d (1+ d))
  )
  (command /r)
;
  (setq dd1 1)
  (setq cc1 1)
  (if (= wd "f")
  (while (<= cc1 10)
  (if (= cc "20")
  (setq dd3 "n")
  (setq dd1 2))
  (if (= cc "25")
  (setq dd3 "n"))
  (if (= cc "25")
   (setq dd1 1))
  (setq cc1 20)
  )
 )
 ;
 (setq cc1 1)
  (if (= wd "w")
  (while (<= cc1 10)
  (if (= c 3)
  (setq dd3 "n")
  (setq dd1 2))
  (setq cc1 20)
  )
  )
;
;
  (setq a (read-line fs) b (read a))
  (setq s6 (list (car b) (cadr b)))
   (command "pline" c2 "w" "0.05" "" s6 /r)
  (setq s5 (getstring "\n对加入最后一点满意吗?(Y/N):"))
  (IF (OR (= S5 "Y") (= S5 "y"))
  (setq s5 "y"))
  (if (or (= s5 "n") (= s5 "N"))
  (setq s5 "n"))
  (if (= s5 "n")
 (command "u"))
  (if (/= s5 "n")
  (setq s4 s6)
  (setq s4 c2))
;
  (command "osnap" "nearest")
  (setq d11 "n")
   (setq d11 (getstring "\n需要对等势线修改?(Y/N):"))
  (IF (OR (= d11 "y") (= d11 "Y"))
  (setq d11 "y"))
  (IF (OR (= d11 "n") (= d11 "N"))
  (setq d11 "n"))
   (setq d2 1)
   (if (= d11 "y")
    (while (<= d2 20)
  (setq m5 (car c2))
  (setq m6 (cadr c1))
  (setq m7 (cadr c2))
   (if (>= m4 m5)
  (setq m4 (+ m4 35.0))
  (setq m5 (+ m5 35.0)))
   (if (>= m4 m5)
   (setq m5 (- m5 35.0))
   (setq m4 (- m4 35.0)))
   (if (>= m6 m7)
  (setq m6 (+ m6 35.0))
  (setq m7 (+ m7 35.0)))
   (if (>= m6 m7)
   (setq m7 (- m7 35.0))
   (setq m6 (- m6 35.0)))
 (command "zoom" "w" (list m4 m6) (list m5 m7) /r)
   (command "zoom" "0.8x" /r)
    (setq d3 (getstring "\n对等势线拟合?(Y/N):"))
  (IF (OR (= d3 "y") (= d3 "Y"))
  (setq d3 "y"))
  (IF (OR (= d3 "n") (= d3 "N"))
  (setq d3 "n"))
    (setq d4 1)
    (if (= d3 "y")
   (while (<= d4 20)
   (COMMAND "pedit" "l" "f" "x")
  (setq d3 (getstring "\n满意吗?(Y/N):"))
  (IF (OR (= d3 "y") (= d3 "Y"))
  (setq d3 "y"))
  (IF (OR (= d3 "n") (= d3 "N"))
  (setq d3 "n"))
  (IF (= d3 "n")
   (command "u"))
   (setq d4 30)
   )
   )
;
    (setq d3 (getstring "\n插入(起始)新点?(Y/N):"))
  (IF (OR (= d3 "y") (= d3 "Y"))
  (setq d3 "y"))
  (IF (OR (= d3 "n") (= d3 "N"))
  (setq d3 "n"))
    (setq d4 1)
    (if (= d3 "y")
   (while (<= d4 20)
    (setq d5 (getpoint "\n插入起始点:"))
   (command "pline" c1 "w" "0.05" "" d5 "")
  (setq d3 (getstring "\n满意吗?(Y/N):"))
  (IF (OR (= d3 "y") (= d3 "Y"))
  (setq d3 "y"))
  (IF (OR (= d3 "n") (= d3 "N"))
  (setq d3 "n"))
  (IF (= d3 "n")
   (command "u"))
  (if (= d3 "n")
   (setq d4 1)
   (setq d4 30))
   )
   )
;
  (setq d3 (getstring "\n(最后点)延伸吗?(Y/N):"))
  (IF (OR (= d3 "y") (= d3 "Y"))
  (setq d3 "y"))
  (IF (OR (= d3 "n") (= d3 "N"))
  (setq d3 "n"))
  (setq d4 1)
   (if (= d3 "y")
   (while (<= d4 20)
  (setq s11 (getpoint "\n目标:"))
  (command "pline" s4 "w" "0.05" "" s11 "")
  (setq d3 (getstring "\n满意吗?(Y/N):"))
  (IF (OR (= d3 "y") (= d3 "Y"))
  (setq d3 "y"))
  (IF (OR (= d3 "n") (= d3 "N"))
  (setq d3 "n"))
  (IF (= d3 "n")
   (command "u"))
  (if (= d3 "n")
   (setq d4 1)
  (setq d4 30))
  )
  )
;
;
  (command "zoom" "p" /r)
  (command "zoom" "p" /r)
   (setq d2 30)
   )
  )
;
  (command "text" s7 nb s8 s2 /r)
;
  (setq cc1 1)
  (if (= wd "w")
  (while (<= cc1 10)
  (setq t 1)
  (if (= c 3)
  (while (<= t 20)
  (setq m4 (car m1))
  (setq m5 (cadr m1))
  (setq m6 (* mm1 4.0))
  (setq m7 (* mm1 3.0))
  (if (< m4 ll)
   (setq m8 (- m4 m6))
  (setq m8 (+ m4 m6)))
  (if (= wd "f")
  (setq sb1 (car bs)))
 (if (= wd "f")
  (setq sb2 (cadr bs)))
  (if (= wd "f")
  (setq sb3 (/ (- sb1 sb2) 2.0)))
   (if (= wd "f")
  (setq m9 (+ sb2 sb3))
  (setq m9 (+ m5 m6)))
  (setq m4 (+ m8 1.0))
  (setq m5 (+ m9 1.0))
  (command "shape" "a04" (list m4 m5) mm "0.0")
  (setq m4 (+ m8 m7))
  (command "pline" m1 "w" "0.05" "" (list m8 m9) (list m4 m9) "")
  (setq t 39)
;
)
 )
  (setq cc1 20)
  )
  )
;
  (setq cc1 1)
  (if (= wd "f")
  (while (<= cc1 10)
  (setq t 1)
  (if (= cc "20")
  (while (<= t 20)
  (setq m4 (car m1))
  (setq m5 (cadr m1))
  (setq m6 (* mm1 6.0))
  (setq m7 (* mm1 3.5))
  (if (< m4 ll)
   (setq m8 (- m4 m6))
  (setq m8 (+ m4 m6)))
  (if (= wd "f")
  (setq sb1 (car bs)))
 (if (= wd "f")
  (setq sb2 (cadr bs)))
  (if (= wd "f")
  (setq sb3 (/ (- sb1 sb2) 2.0)))
   (if (= wd "f")
  (setq m9 (+ sb2 sb3))
  (setq m9 (+ m5 m6)))
  (setq m9 (+ m9 2.0))
  (setq m4 (+ m8 1.0))
  (setq m5 (+ m9 1.0))
  (command "shape" "a04" (list m4 m5) mm "0.0")
  (setq m4 (+ m8 m7))
  (command "pline" m1 "w" "0.05" "" (list m8 m9) (list m4 m9) "")
  (setq t 39)
;
)
 )
  (setq cc1 20)
  )
  )
;
  (setq cc1 1)
  (if (= wd "f")
  (while (<= cc1 10)
  (setq t 1)
  (if (= cc "25")
  (while (<= t 20)
  (setq m4 (car m1))
  (setq m5 (cadr m1))
  (setq m6 (* mm1 6.5))
  (setq m7 (* mm1 2.5))
  (if (< m4 ll)
   (setq m8 (- m4 m6))
  (setq m8 (+ m4 m6)))
  (if (= wd "f")
  (setq sb1 (car bs)))
 (if (= wd "f")
  (setq sb2 (cadr bs)))
  (if (= wd "f")
  (setq sb3 (/ (- sb1 sb2) 2.0)))
   (if (= wd "f")
  (setq m9 (+ sb2 sb3))
  (setq m9 (+ m5 m6)))
  (setq m9 (+ m9 2.0))
  (setq m4 (+ m8 1.0))
  (setq m5 (+ m9 1.0))
  (command "shape" "a04" (list m4 m5) mm "0.0")
  (setq m4 (+ m8 m7))
  (command "pline" m1 "w" "0.05" "" (list m8 m9) (list m4 m9) "")
  (setq t 39)
;
)
 )
  (setq cc1 20)
  )
  )
;
  (setq c (1+ c))
   (if (= l2 10)
  (setq c 1185))
   (if (= l2 0)
  (setq c 1125))
   (if (= l2 1)
  (setq c 1125))
   (if (= l2 5)
  (setq c 1125))
  )
  (command "zoom" "e" /r)
;
;
 )
;
(defun lsw4()
      (setq a 1)
   (setq g2 0)
   (setq g3 0)
           (while (<= a 2)
    (setq g2 (1+ g2))
    (setq g3 (1+ g3))
           (command "layer" "m" g2 "c" g3 g2 /r)
     (setq a (1+ a))
   )
   (command "load" "a:lsw")
                (command "layer" "s" "1" /r)
  (command "aperture" "6" /r)
  (command "osnap" "off")
  (setq ms "dqb1.map")
  (setq fs (open ms "r"))
  (setq s11 1000.0)
  (setq s10 0.0)
  (setq s02 1000.0)
  (setq s01 0.0)
;
  (setq a (read-line fs) b (read a))
  (setq xs (car b))
;
;
  (setq a (read-line fs) b (read a))
  (setq m1 (car b))
  (setq m2 (cadr b))
  (setq c 1)
  (while (<= c m1)
  (setq a (read-line fs) b (read a))
  (setq s1 (list (car b) (cadr b)))
  (setq s2 (list (nth 2 b) (nth 3 b)))
  (setq s3 (list (nth 4 b) (nth 5 b)))
  (setq s4 (list (nth 6 b) (nth 7 b)))
  (command "pline" s1 "w" "0.04" "0.04" s2 s3 s4 s1 /r)
  (setq s21 (car s1))
  (setq s31 (car s2))
  (setq s41 (car s3))
  (setq s51 (car s4))
  (setq s22 (cadr s1))
  (setq s32 (cadr s2))
  (setq s42 (cadr s3))
  (setq s52 (cadr s4))
  (if (> s10 s21)
  (setq s10 s10) (setq s10 s21))
  (if (> s10 s31)
  (setq s10 s10) (setq s10 s31))
  (if (> s10 s41)
  (setq s10 s10) (setq s10 s41))
  (if (> s10 s51)
  (setq s10 s10) (setq s10 s51))
  (if (< s11 s21)
  (setq s11 s11) (setq s11 s21))
  (if (< s11 s31)
  (setq s11 s11) (setq s11 s31))
  (if (< s11 s41)
  (setq s11 s11) (setq s11 s41))
  (if (< s11 s51)
  (setq s11 s11) (setq s11 s51))
  (if (> s01 s22)
  (setq s01 s01) (setq s01 s22))
  (if (= s01 s22)
  (setq m6 s21))
  (if (> s01 s32)
  (setq s01 s01) (setq s01 s32))
  (if (= s01 s32)
  (setq m6 s31))
  (if (> s01 s42)
  (setq s01 s01) (setq s01 s42))
  (if (= s01 s42)
  (setq m6 s41))
  (if (> s01 s52)
  (setq s01 s01) (setq s01 s52))
  (if (= s01 s52)
  (setq m6 s51))
  (if (< s02 s22)
  (setq s02 s02) (setq s02 s22))
  (if (< s02 s32)
  (setq s02 s02) (setq s02 s32))
  (if (< s02 s42)
  (setq s02 s02) (setq s02 s42))
  (if (< s02 s52)
  (setq s02 s02) (setq s02 s52))
;
  (setq x1 (car s1))
  (setq x2 (car s2))
  (setq x3 (car s3))
  (setq x4 (car s4))
  (setq x5 (+ x1 x2))
  (setq x5 (+ x5 x3))
  (setq x5 (+ x5 x4))
  (setq x5 (/ x5 4.0))
  (setq y1 (cadr s1))
  (setq y2 (cadr s2))
  (setq y3 (cadr s3))
  (setq y4 (cadr s4))
  (setq y5 (+ y1 y2))
  (setq y5 (+ y5 y3))
  (setq y5 (+ y5 y4))
  (setq y5 (/ y5 4.0))
   (setq y5 (- y5 4.0))
   (setq y6 (+ y5 5.0))
  (setq a (read-line fs) b (read a))
  (setq k1 (car b))
  (setq k2 (cadr b))
  (setq k3 (nth 2 b))
  (setq k4 (nth 3 b))
  (setq k5 (nth 4 b))
  (setq k6 (nth 5 b))
  (setq k7 (nth 6 b))
  (setq k8 (nth 7 b))
  (setq k9 (nth 8 b))
  (setq k1 (itoa k1))
  (setq k2 (itoa k2))
  (setq k3 (itoa k3))
  (setq k4 (itoa k4))
  (setq k5 (itoa k5))
  (setq k6 (itoa k6))
  (setq k7 (itoa k7))
  (setq k8 (itoa k8))
  (setq k9 (itoa k9))
  (setq cc (itoa c))
 (setq m9 (max x1 x2 x3 x4))
 (setq m22 (min x1 x2 x3 x4))
 (setq m3 (max y1 y2 y3 y4))
 (setq m4 (min y1 y2 y3 y4))
 (setq m5 (- m9 m22))
 (setq m6 (- m3 m4))
 (setq m7 (* m5 m6))
 (setq m8 (* 5.0 60))
 (setq m0 1)
 (if (> m7 m8)
 (while (<= m0 10)
  (setq cc (strcat "(" cc ")"))
  (setq k9 (strcat "K" k9))
  (command "text" "c" (list x5 y5) "2.5" "0.0" k9)
  (command "text" "c" (list x5 y6) "2.5" "0.0" cc)
   (setq xx1 (+ x1 x2))
   (setq xx1 (/ xx1 2.0))
   (setq xx1 (- xx1 1.0))
   (setq yy1 (+ y1 y2))
   (setq yy1 (/ yy1 2.0))
   (setq yy1 (- yy1 3.5))
   (command "text" "c" (list xx1 yy1) "2.5" "0.0" k5)
   (setq xx2 (+ x2 x3))
   (setq xx2 (/ xx2 2.0))
   (setq xx2 (- xx2 1.0))
   (setq yy2 (+ y2 y3))
   (setq yy2 (/ yy2 2.0))
   (setq yy2 (- yy2 3.5))
   (command "text" "r" (list xx2 yy2) "2.5" "0.0" k6)
   (setq xx3 (+ x3 x4))
   (setq xx3 (/ xx3 2.0))
   (setq xx3 (- xx3 1.0))
   (setq yy3 (+ y3 y4))
   (setq yy3 (/ yy3 2.0))
   (setq yy3 (+ yy3 1.0))
   (command "text" "c" (list xx3 yy3) "2.5" "0.0" k7)
   (setq xx4 (+ x4 x1))
   (setq xx4 (/ xx4 2.0))
   (setq xx4 (+ xx4 1.0))
   (setq yy4 (+ y4 y1))
   (setq yy4 (/ yy4 2.0))
   (setq yy4 (- yy4 3.5))
   (command "text" (list xx4 yy4) "2.5" "0.0" k8)
  (setq m0 30)
  )
 )
  (setq c (1+ c))
;
   )
;
  (setq s22 (+ s01 50.0))
  (setq s1 (- s10 s11))
  (setq s1 (/ s1 2.0))
  (setq s1 (+ s11 s1))
  (setq s31 (- s1 32.0))
  (setq s32 (+ s1 24.0))
  (setq s41 (+ s22 1.0))
  (setq s42 (+ s31 1.0))
  (setq s41 (list s42 s41))
  (setq s52 (list s32 s22))
  (setq s51 (list s31 s22))
  (command "pline" s51 "w" "0.5" "" s52 "")
  (command "shape" "a14" s41 "7.0" "0.0")
;
  (command "zoom" "e")
;
                (command "layer" "s" "2" /r)
  (setq c 1)
  (while (<= c m2)
  (setq a (read-line fs) b (read a))
  (setq x1 (car b))
  (setq y1 (cadr b))
   (setq y1 (- y1 1.25))
  (setq cc (itoa c))
  (command "text" "c" (list x1 y1) "2.5" "0.0" cc)
  (setq c (1+ c))
   )
  (setq x1 s11)
  (setq x2 s10)
  (setq y1 s02)
  (setq y2 s01)
  ;
  )
;
(defun lsw5()
  (command "aperture" "5" /r)
  (command "osnap" "nearest")
  (setq s1 (getstring "\n添加外边坡轮廓线吗(Y/N)?"))
  (IF (OR (= s1 "y") (= s1 "Y"))
  (setq s1 "y"))
  (IF (OR (= s1 "n") (= s1 "N"))
  (setq s1 "n"))
  (setq a 1)
  (if (= s1 "y")
  (while (<= a 10)
  (setq x1 (getpoint "\n坝底第一外边坡点:"))
  (command "osnap" "off")
  (setq x2 (getpoint "\n坝顶第一外边坡点:"))
  (setq y2 (getpoint "\n坝顶第二外边坡点:"))
  (command "osnap" "nearest")
  (setq y1 (getpoint "\n坝底第二外边坡点:"))
  (setq x5 (car x2))
  (setq y5 (cadr x2))
  (setq x6 (car y2))
  (setq y6 (cadr y2))
  (setq y6 (list x6 y5))
  (command "pline" x1 "w" "0.06" "0.06" x2 y6 y1 /r)
  (setq x4 (getstring "\n瞒意吗(Y/N)?"))
  (IF (OR (= x4 "y") (= x4 "Y"))
  (setq x4 "y"))
  (IF (OR (= x4 "n") (= x4 "N"))
  (setq x4 "n"))
  (if (= x4 "n")
   (command "u"))
   (IF (= x4 "n")
  (setq a 3)
  (setq a 30)
  )
;
    )
  )
;
  (setq c 1)
  (setq xx (getstring "\n开窗吗(Y/N)?"))
  (IF (OR (= xx "y") (= xx "Y"))
  (setq xx "y"))
  (IF (OR (= xx "n") (= xx "N"))
  (setq xx "n"))
  (if (= xx "y")
  (while (<= c 10)
  (setq x2 (getpoint "\n窗口第一点:"))
  (setq x3 (getpoint "\n窗口第二点:"))
  (command "zoom" "w" x2 x3 )
  (setq c 20)
  )
  )
;
  (setq s1 (getstring "\n添加内边坡轮廓线吗(Y/N)?"))
  (IF (OR (= s1 "y") (= s1 "Y"))
  (setq s1 "y"))
  (IF (OR (= s1 "n") (= s1 "N"))
  (setq s1 "n"))
  (setq a 1)
  (if (= s1 "y")
  (while (<= a 10)
; (command "aperture" "6" /r)
; (if (= a 1)
  (setq x1 (getpoint "\n底部第一内边坡点:"))
  (setq x2 (getpoint "\n顶部第一内边坡点:"))
  (setq y2 (getpoint "\n顶部第二内边坡点:"))
  (setq y1 (getpoint "\n底部第二内边坡点:"))
  (setq x5 (car x2))
  (setq y5 (cadr x2))
  (setq x6 (car y2))
  (setq y6 (cadr y2))
  (setq y6 (list x6 y5))
  (command "pline" x1 "w" "0.04" "0.04" x2 y6 y1 /r)
  (setq x4 (getstring "\n瞒意吗(Y/N)?"))
  (IF (OR (= x4 "y") (= x4 "Y"))
  (setq x4 "y"))
  (IF (OR (= x4 "n") (= x4 "N"))
  (setq x4 "n"))
  (if (= x4 "n")
   (command "u"))
   (IF (= x4 "n")
  (setq a 3)
  (setq a 30)
  )
;
    )
  )
  (if (= xx "y")
  (command "zoom" "p" ))
;
)
;
 (defun lsw0()
  (setq x3 (- x2 x1))
  (setq y3 (- y2 y1))
  (setq x3 (+ x3 18.0))
  (setq y3 (+ y3 45.0))
  (if (<= x3 1189.0)
  (setq m1 0))
  (if (<= x3 841.0)
  (setq m1 1))
  (if (<= x3 594.0)
  (setq m1 2))
  (if (<= x3 420.0)
  (setq m1 3))
  (if (<= x3 297.9)
  (setq m1 4))
  (if (= m1 0)
  (setq y4 (- 841.0 y3)))
  (if (= m1 1)
  (setq y4 (- 594.0 y3)))
  (if (= m1 2)
  (setq y4 (- 420.0 y3)))
  (if (= m1 3)
  (setq y4 (- 297.0 y3)))
  (if (= m1 4)
  (setq y4 (- 210.0 y3)))
;
  (if (= m1 0)
  (setq x4 (- 1189.0 x3)))
  (if (= m1 1)
  (setq x4 (- 841.0 x3)))
  (if (= m1 2)
  (setq x4 (- 594.0 x3)))
  (if (= m1 3)
  (setq x4 (- 420.0 x3)))
  (if (= m1 4)
  (setq x4 (- 297.9 x3)))
;
  (setq x4 (/ x4 2.0))
  (setq y4 (/ y4 2.0))
  (setq x4 (- x1 x4))
  (setq y4 (- y1 y4))
  (setq x4 (- x4 15.0))
  (setq y4 (- y4 5.0))
     (SETQ A (1+ 1))
   (while (<= a 20)
;
    (command "layer" "s" "2" /r)
;
  (setq s2 (list x4 y4))
    (setq s4 (car s2))
    (setq s6 (cadr s2))
   (if (= m1 0)
   (setq s3 (+ s4 1189.0)))
   (if (= m1 0)
   (setq s5 (+ s6 841.0)))
   (if (= m1 1)
   (setq s3 (+ s4 841.0)))
   (if (= m1 1)
   (setq s5 (+ s6 594.0)))
   (if (= m1 2)
   (setq s3 (+ s4 594.0)))
   (if (= m1 2)
   (setq s5 (+ s6 420.0)))
   (if (= m1 3)
   (setq s3 (+ s4 420.0)))
   (if (= m1 3)
   (setq s5 (+ s6 297.0)))
   (if (= m1 4)
   (setq s3 (+ s4 297.9)))
   (if (= m1 4)
   (setq s5 (+ s6 210.0)))
    (setq s11 (list s3 s6))
  (setq m11 s11)
    (setq s7 (list s3 s5))
    (setq s9 (list s4 s5))
  (command "pline" s2 "w" "0.5" "0.5" s11 s7 s9 "c")
;
   (setq k2 (+ s4 10.0))
   (setq k3 (- s5 20.0))
  (setq k1 (list k2 k3))
  (command "text" k1 "4.2" "0.0" xs)
;
   (if (= m1 0)
   (setq s4 (- s4 25.0)))
 (if (= m1 0)
     (setq s6 (- s6 10.0)))
    (if (= m1 0)
    (setq s3 (+ s3 10.0)))
    (if (= m1 0)
    (setq s5 (+ s5 10.0)))
   (if (= m1 1)
   (setq s4 (- s4 25.0)))
 (if (= m1 1)
     (setq s6 (- s6 10.0)))
    (if (= m1 1)
    (setq s3 (+ s3 10.0)))
    (if (= m1 1)
    (setq s5 (+ s5 10.0)))
   (if (= m1 2)
   (setq s4 (- s4 25.0)))
 (if (= m1 2)
     (setq s6 (- s6 10.0)))
    (if (= m1 2)
    (setq s3 (+ s3 10.0)))
    (if (= m1 2)
    (setq s5 (+ s5 10.0)))
   (if (= m1 3)
   (setq s4 (- s4 25.0)))
 (if (= m1 3)
     (setq s6 (- s6 5.0)))
    (if (= m1 3)
    (setq s3 (+ s3 5.0)))
    (if (= m1 3)
    (setq s5 (+ s5 5.0)))
   (if (= m1 4)
   (setq s4 (- s4 25.0)))
 (if (= m1 4)
     (setq s6 (- s6 5.0)))
    (if (= m1 4)
    (setq s3 (+ s3 5.0)))
    (if (= m1 4)
    (setq s5 (+ s5 5.0)))
    (setq s8 (list s3 s6))
    (setq s7 (list s3 s5))
    (setq s9 (list s4 s5))
   (setq s10 (list s4 s6))
   (command "pline" s10 "w" "0.05" "0.05" s8 s7 s9 "c")
  (setq s2 "y")
   (IF (= S2 "n") (setq a (1+ 1)) (setq a (1+ 30)))
   (IF (= S2 "n") (command "u" /r))
   (IF (= S2 "n") (command "u" /r))
   (IF (= S2 "n") (command "u" /r))
 )
;)
;
 )
;
  (defun c:lsw()
 (setq bs1 1)
  (while (<= bs1 20)
  (setq s1 (getstring "\n绘流网图(L)or结构图(J):?"))
  (IF (OR (= s1 "l") (= s1 "L"))
  (setq s1 "l"))
  (IF (OR (= s1 "j") (= s1 "J"))
  (setq s1 "j"))
  (setq a 1)
  (IF (= s1 "l")
  (while (<= a 10)
  (lsw1)
 (lsw0)
  (command "zoom" "e" /r)
  (lsw2)
 (lsw3)
  (setq s2 (getstring "\n添加轮廓线吗(Y/N)?"))
  (IF (OR (= s2 "y") (= s2 "Y"))
  (setq s2 "y"))
  (IF (OR (= s2 "n") (= s2 "N"))
  (setq s2 "n"))
  (if (= s2 "y")
 (lsw5)
  )
   (setq a 20)
  )
  )
;
  (setq a 1)
   (if (= s1 "j")
  (while (<= a 20)
  (lsw4)
  (command "zoom" "0.6x" /r)
  (lsw0)
  (setq s2 (getstring "\n添加轮廓线吗(Y/N)?"))
  (IF (OR (= s2 "y") (= s2 "Y"))
  (setq s2 "y"))
  (IF (OR (= s2 "n") (= s2 "N"))
  (setq s2 "n"))
  (if (= s2 "y")
 (lsw5)
)
  (command "zoom" "e" /r)
  (setq a 30)
 )
  )
;
  (setq m1 (getstring "\n记盘吗?(Y/N):"))
  (IF (OR (= M1 "Y") (= M1 "y"))
  (setq m1 "y"))
  (if (or (= m1 "n") (= m1 "N"))
 (setq m1 "n"))
  (if (= m1 "y")
 (setq m2 (getstring "\n记盘文件名:")))
  (if (= m1 "y")
  (command "save" m2 /r))
;
  (setq m1 (getstring "\n继续进行绘图工作吗?(Y/N):"))
  (IF (OR (= M1 "Y") (= M1 "y"))
  (setq m1 "y"))
  (if (or (= m1 "n") (= m1 "N"))
 (setq m1 "n"))
  (if (= m1 "y")
  (setq bs1 10)
  (setq bs1 30)
 )
  (if (= m1 "y")
  (command "erase" "w" (list -500 -500) (list 5000 5000) "")
 )
;
)
;
;
  (setq m1 (getstring "\n退出AUTOCAD吗?(Y/N):"))
  (IF (OR (= M1 "Y") (= M1 "y"))
  (setq m1 "y"))
  (if (or (= m1 "n") (= m1 "N"))
 (setq m1 "n"))
  (if (= m1 "y")
  (command "quit" "Y" "")
   (prompt "         欢迎使用陕西省水电设计院ＡＵＴＯＣＡＤ应用程序!再见"))
  (setq c 1)
)
