[code](setvar "CMDECHO" 0);;;=================================================================*;;;功能:绘制表格 *;;;日期:zml84 于 2009-07-20 *(defun c:bg () (princ "\n绘制表格") (if (and (setq TMP (ZL-INPUTBOX
;;;=================================================================*
;;;功能:绘制表格 *
;;;日期:zml84 于 2009-07-20 *
(defun c:bg ()
(princ "\n绘制表格")
(if (and (setq TMP
(ZL-INPUTBOX
"绘制表格"
'(("editbox" " 行数:" "5" "20")
("editbox" " 列数:" "3" "20")
("editbox" " 每行高度:" "6.0" "20")
("editbox" " 每列宽度:" "15.0" "20")
("editbox" "表中文字字高:" "2.5" "20")
)
)
)
)
(progn
(setq i (read (nth 0 TMP))
j (read (nth 1 TMP))
h (read (nth 2 TMP))
w (read (nth 3 TMP))
size (read (nth 4 TMP))
)
(setq ss1 (bg-draw '(0 0) i j h w))
(setq ss2 (bg-text '(0 0) i j h w size))
(command "_.move" ss1 ss2 "" "non" '(0 0))
)
)
(princ)
)
;;;=================================================================*
;;;参数:pt-----左下角基点 *
;;; i -----行数 *
;;; j -----列数 *
;;; h -----行高 *
;;; w -----列宽 *
;;;测试:(bg-draw '(0 0) 3 2 10 25)
(defun bg-draw (pt i j h w / hh ww ss)
(setq ss (ssadd))
(setq hh (* i h) ;_总高度
ww (* j w) ;_总宽度
)
;;绘制横线
(command "_.pline" "non" pt "non" (polar pt 0 ww) "")
(setq ss (ssadd (entlast) ss))
(repeat i
(command "_.copy"
(entlast)
""
"non"
'(0 0)
"non"
(list 0 h)
)
(setq ss (ssadd (entlast) ss))
)
;;绘制竖线
(command "_.pline"
"non"
pt
"non"
(polar pt (* 0.5 pi) hh)
""
)
(setq ss (ssadd (entlast) ss))
(repeat j
(command "_.copy"
(entlast)
""
"non"
'(0 0)
"non"
(list w 0)
)
(setq ss (ssadd (entlast) ss))
)
;;返回
ss
)
;;;写表格内文字
;;;测试:(bg-text '(0 0) 3 2 10 25)
(defun bg-text (pt i j h w size / pt0 pti ss)
(setq ss (ssadd))
(setq pt0 (polar pt 0 (* 0.5 w))
pt0 (polar pt0 (* 0.5 pi) (* 0.5 h))
)
(repeat i
(setq pti pt0)
(repeat j
(command "_.text" "j" "mc" "non" pti size 0 "****")
(setq ss (ssadd (entlast) ss))
(setq pti (polar pti 0 w))
)
(setq pt0 (polar pt0 (* 0.5 pi) h)
)
)
;;返回
ss
)[/code]