(defun c:CHG (/ FS F Z H FF ZZ)
   (setq olderr *error* 
       *error* ai_abort) 
   (command "_.UNDO" "_GROUP")
   (initget 1 "F f Z z H h")
   (setq FS (getkword "\n请选择方式:正换负F/负换正Z/互换H?<F/Z/H>:"))
   (cond ((= FS "F") (ch))
         ((= FS "Z") (ab))
         ((= FS "H") (cd))
    )
)

(defun ch (/ n en ed ostr nstr b)
     (setq n 0 en (ssget '((0 . "TEXT")(62 . 2))))
     (repeat (sslength en)  
     (setq ed (entget (ssname en n)))
     (if (and (= (cdr (assoc 0 ed)) "TEXT") (/= (cdr (assoc 1 ed)) "0.000"))
          (progn  
              (setq ostr (assoc 1 ed))
              (setq b (cdr ostr))
              (if  (/= (substr b 1 1) "-")
                   (progn
                   (setq nstr (strcat "-" b))
                   (setq ed (subst (cons 1 nstr) ostr ed))
                   (entmod ed)
                   )
               )
          )  
     )
     (setq n (1+ n))
   )
)               
 (defun ab (/ n en ed ostr nstr b)
     (setq n 0 en (ssget '((0 . "TEXT")(62 . 2))))
     (repeat (sslength en)  
     (setq ed (entget (ssname en n)))
     (if (= (cdr (assoc 0 ed)) "TEXT")
          (progn  
              (setq ostr (assoc 1 ed))
              (setq b (cdr ostr))
              (if  (= (substr b 1 1) "-")
                   (progn
                   (setq nstr (substr b 2))
                   (setq ed (subst (cons 1 nstr) ostr ed))
                   (entmod ed)
                   )
               )
          )  
     )
     (setq n (1+ n))
   )
)               
 
(defun cd (/ n en ed ostr nstr b)
     (setq n 0 en (ssget '((0 . "TEXT")(62 . 2))))
     (repeat (sslength en)  
       (setq ed (entget (ssname en n)))
       (if (and (= (cdr (assoc 0 ed)) "TEXT") (/= (cdr (assoc 1 ed)) "0.000"))
                 (progn
                  (setq ostr (assoc 1 ed))
                  (setq b (cdr ostr))
                  (if (= (substr b 1 1) "-")
                     (setq nstr (substr b 2))
                     (setq nstr (strcat "-" b))
                  )
                 )
        )
        (setq ed (subst (cons 1 nstr) ostr ed))
        (entmod ed)
      (setq n (1+ n))  
     )
    (setq *error* olderr)  (command "_.UNDO" "_E")
    (princ)
)

;*** 后叙 ***
(princ "\n  Type-------------< CHG >   to run this program.") 
(princ)
                                                                                       