;********标注X轴的尺寸********
(defun c:lx (/ pw pl lx_xy l_xxy oco l_xy pox L_ORD X_X Y_Y X_X_Y X_X_Y ocm obl osc)
  (setq ocm (getvar "cmdecho") 
	obl (getvar "blipmode")
        osc (getvar "osmode")
        oco (getvar "cecolor")
	olderr *error*		     *error* ai_abort)
  (setvar "cmdecho" 0)     (command "_.UNDO" "_GROUP")    
  (setvar "blipmode" 0)      (command "cecolor" 2)
  (setq lx_xy (open "c:/data.dat" "r")) 
  (setq l_xxy (read-line lx_xy))
  (setq l_xy (read l_xxy))
  (close lx_xy)
  (setq pl (car l_xy)
        pw (last l_xy))
  (setq pox 0)
  (while (/= pox nil)
  (setvar "osmode" 1) 
  (initget 1)
  (setq pox (osnap (getpoint "\n请选择需标注位置尺寸的线") "endp"))
  (setvar "osmode" 0) 
  (if pox
    (progn
      (setq X_X (car pox) 
            Y_Y (nth 1 pox))
      (if (< Y_Y 0)
       (setq X_X_Y -1)
       (setq X_X_Y 1)
      )
      (setq L_ORD (/ pw (* 2 X_X_Y)))
      (command "dim" "ordinate" pox (list X_X (+ L_ORD (* pl 0.02 X_X_Y))) "" "e")
     )
   )
   )
   (princ)
   (command "CIRCLE" "0,0" "1" "erase" (entlast) "" "redraw")
   (setq *error* old_er)
   (setvar "cmdecho" ocm) (setvar "blipmode" obl) (setvar "osmode" osc) (command "cecolor" oco)
   (princ)
   )

;********标注y轴的尺寸********
(defun c:ly (/ oco poy pl W_ORD O_Y C_Y n ny X_X_X Y_Y_Y Y_Y_X ocm obl osc olderr *error*)
  (setq ocm (getvar "cmdecho") 
	obl (getvar "blipmode")
	osc (getvar "osmode")
 	oco (getvar "cecolor")
	olderr *error*		     *error* ai_abort)
  (setvar "cmdecho" 0) (setvar "blipmode" 0)  (command "cecolor" 2)
  (setq lx_xy (open "c:/Autolisp/data.dat" "r")) 
  (setq l_xxy (read-line lx_xy))
  (setq l_xy (read l_xxy))
  (close lx_xy)
  (setq pl (car l_xy))
  (setq poy 0)
  (while (/= poy nil)
    (setvar "osmode" 1) 
    (initget 1)
    (setq poy (osnap (getpoint "\n请选择需标注位置尺寸的线") "endp"))
    (setvar "osmode" 0) 
    (if poy
      (progn
        (setq X_X_X (car poy)
	      Y_Y_Y (nth 1 poy))
        (if (< X_X_X 0)
            (setq Y_Y_X -1)
            (setq Y_Y_X 1)
        )
             (setq W_ORD (/ pl (* 2 Y_Y_X)))
             (command "dim" "ordinate" poy (list (+ W_ORD (* pl 0.02 Y_Y_X)) Y_Y_Y) "" "e")
       )
     )  
    )
  (princ)
  (command "CIRCLE" "0,0" "1" "erase" (entlast) "" "redraw")
  (setvar "cmdecho" ocm) (setvar "blipmode" obl) (setvar "osmode" osc) (command "cecolor" oco)
  (setq *error* old_er)
  (command "_.UNDO" "_E") 
  (princ)
)
;*** 后叙 ***
