(defun con () (command "linetype" "s" "continuous" "" "color" 4))
(defun c:pk (/ pock_w pock_l pock_d pock_r PK_R FILL_R text_p I_D_R oco ocm obl 
              ptp1 ptp2 ptp3 ptp4 lx_xy l_xxy l_xy pl pw) 
     (setq *error* ai_abort 
	   ocm (getvar "cmdecho") 
	   obl (getvar "blipmode")
	   oco (getvar "cecolor"))
  (setvar "cmdecho" 0) 	(command "_.UNDO" "_GROUP")  (setvar "blipmode" 0)
  (initget 1)
  (setq POCK_L (getreal "\n请输入框的宽度:"))
  (initget 1)
  (setq POCK_W (getreal "\n请输入框的长度:")
	POCK_D (getreal "\n深度:"))
  (if (AND (>= POCK_D 0)  (< POCK_D 20))  (setq PK_R 8))
  (if (AND (>= POCK_D 20) (< POCK_D 40))  (setq PK_R 10))
  (if (AND (>= POCK_D 40) (< POCK_D 70))  (setq PK_R 13))
  (if (AND (>= POCK_D 70) (< POCK_D 150))  (setq PK_R 16))
  (if (AND (>= POCK_D 150) (< POCK_D 170))  (setq PK_R 18))
  (if (AND (>= POCK_D 170) (< POCK_D 200))  (setq PK_R 21))
  (if (AND (>= POCK_D 200)  (< POCK_D 250))  (setq PK_R 27))
  (if (AND (>= POCK_D 250)  (< POCK_D 400))  (setq PK_R 33))
  (if (AND (>= POCK_D 400)  (< POCK_D 500))  (setq PK_R 42))
  (if (= POCK_D nil) (setq PK_R 16))
  (setq POCK_R (getreal (strcat "\n圆角半径:<"(rtos PK_R )">")))
  (if (= POCK_R nil)
      (setq FILL_R PK_R)
      (setq FILL_R POCK_R))
  (setq ptp1 (list (* (/ POCK_L 2) -1) (* (/ POCK_W 2) -1))
	ptp2 (list (car ptp1) (* (cadr ptp1) -1))    
	ptp3 (list (/ POCK_L 2) (/ POCK_W 2))               
	ptp4 (list (car ptp3) (cadr ptp1)))        
  (con)(rectang ptp1 ptp3)
  (command "fillet" "r" FILL_R 
	   "fillet" "p" "l" "explode" "l")
(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)
        pw (last l_xy))
      (setq L_ORD (/ pw 2)
            W_ORD (/ pl 2)
	    I_D_R (* FILL_R 0.4142)
            pox1 (list (car ptp2) (- (cadr ptp2) FILL_R))
	    pox2 (list (car ptp3) (- (cadr ptp3) FILL_R))
  	    poy1 (list (- (car ptp3) FILL_R) (cadr ptp3))
            poy2 (list (- (car ptp4) FILL_R) (cadr ptp4)))
      (command "cecolor" "2" "dim" 
	     "ordinate" pox1 (list (car pox1) (+ L_ORD (* pl 0.02))) ""
       	     "ordinate" pox2 (list (car pox2) (+ L_ORD (* pl 0.02))) "" 
       	     "ordinate" poy1 (list (+ W_ORD (* pl 0.02)) (cadr poy1)) ""
       	     "ordinate" poy2 (list (+ W_ORD (* pl 0.02)) (cadr poy2)) "" 
             "leader" (polar ptp1 (/ pi 4) I_D_R) 
             (polar (polar ptp1 (/ pi 4) I_D_R) (/ pi 4) (* POCK_L POCK_W 0.0002)) "" 
		    (strcat "R" (rtos FILL_R)) "e")
 (if (= POCK_D nil)
   (setq text_p "通框")
   (setq text_p (strcat "-" (rtos POCK_D))))
   (command "text" (polar ptp2 (/ pi -3) (/ POCK_L 5)) (* (getvar "dimscale") 0.18) "0" text_p)
  (setvar "cmdecho" ocm) (setvar "blipmode" obl) 
  (setvar "cecolor" oco)
  (setq *error* olderr) (command "_.UNDO" "_E")
  (princ)
  )

;*** 后叙 ***
(princ "\n  Type-------------< pk >   to run this program.") 
(princ "\n  歡迎使用Autolisp二次開發程序!本程序由 比達 收集整理。如有疑問請聯系QQ：89113144.")
(princ)
