找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1605|回复: 5

[LISP程序]:表格绘制程序

[复制链接]
发表于 2003-6-11 15:30:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
附件是原始文件

  1. ;|
  2. 这个程序有点意思,想法挺好。原来的对话框布局不太美观,调整了一下。顺手也给汉化了。
  3. 程序会新建图层TABLE,颜色红色,表格内文本高度根据当前尺寸标注的相关变量
  4. 自动适应。最终的表格宽度会自动根据单元字符长度自适应。不错。
  5. 唯一的遗憾是行列最多为10,并且输入时不时很方便(但很直观,新手应该喜欢 :))。
  6. |;
  7. (Defun C:TABLE (/              CR            DLG_CLOSE          DLG_HEADER
  8.                 DLG_DIALOG    DLG_ITEM            DLG_PROTO          DLG_ATT
  9.                 SYMTOS              DCL_TEMP            DCL_MATRIX          DCL_MATRIX_HED
  10.                 SET_COL              GET_COL            SET_ROW          GET_ROW
  11.                 GET_QTY              CHECK_NEXT    SET_NEXT_MATRIX_ITEM
  12.                 TOGG_ASSOC    OL            OS                  OC
  13.                 DLG_MAIN      DELETE_TEMP_DCL                  DLG_MATRIX
  14.                 DLG_MATRIX_HEAD                    GET_MATRIX
  15.                 GET_MATRIX_HEAD                    DRAW_TABLE
  16.                 DRAW_TABLE_HEAD                    *TABLEID*          FD
  17.                 ROW_NDX              COL_NDX            COL_QTY          COL_NUM
  18.                 COL_INPUT     NO_OF_COLS    ROW_QTY          ROW_NUM
  19.                 ROW_INPUT     NO_OF_ROWS    FLAG          NEXT_MATRIX
  20.                 TOG_VALUE     INCL            DCL_ID          TITLE
  21.                 DS              OSMODE            CECOLOR          CLAYER
  22.                 SCALE              SIZE            HALFSIZE          TITLESIZE
  23.                 SP              CNT            TOTAL_WIDTH          TOTAL_HEIGHT
  24.                )
  25. ;;;;;Main dialog control functions;;;;
  26.   (Defun CR () (princ "\n" FD))
  27.   (Defun DLG_CLOSE () (princ "}" FD) (CR))
  28.   (Defun DLG_HEADER (AUDIT)
  29.     (princ "dcl_settings : default_dcl_settings {" FD)
  30.     (CR)
  31.     (princ (strcat " audit_level = " (itoa AUDIT) "; }") FD)
  32.     (CR)
  33.   ) ;_ end of Defun
  34.   (Defun DLG_DIALOG (NAME)
  35.     (princ (strcat NAME " : dialog {") FD)
  36.     (CR)
  37.   )
  38.   (Defun DLG_ITEM (ITEM)
  39.     (princ (strcat ": " ITEM "{") FD)
  40.     (CR)
  41.   )
  42.   (Defun DLG_PROTO (type) (princ (strcat type ";") FD) (CR))
  43.   (Defun DLG_ATT (ATT VAL)
  44.     (cond
  45.       ((= (type VAL) 'INT)
  46.        (princ (strcat ATT "=" (itoa VAL) ";") FD)
  47.        (CR)
  48.       )
  49.       ((= (type VAL) 'REAL)
  50.        (princ (strcat ATT "=" (rtos VAL) ";") FD)
  51.        (CR)
  52.       )
  53.       ((= (type VAL) 'STR)
  54.        (princ (strcat ATT "="" VAL "";") FD)
  55.        (CR)
  56.       )
  57.       ((= (type VAL) 'SYM)
  58.        (princ (strcat ATT "=" (SYMTOS VAL) ";") FD)
  59.        (CR)
  60.       )
  61.     ) ;_ end of cond
  62.   ) ;_ end of Defun
  63.   (Defun SYMTOS        (SYM / FD)
  64.     (setq FD (open "symtos.txt" "w"))
  65.     (princ SYM FD)
  66.     (close FD)
  67.     (setq
  68.       FD  (open "symtos.txt" "r")
  69.       SYM (strcase (read-line FD) t)
  70.     ) ;_ end of setq
  71.     (close FD)
  72.     SYM
  73.   ) ;_ end of Defun
  74.   (Defun DCL_TEMP (/ FD)
  75.     (setq FD (open "temp.dcl" "w"))
  76.     (DLG_HEADER 0)
  77. ;;;Define Main Dialog;;;
  78.     (DLG_DIALOG "dlg_main")
  79.     (DLG_ATT "label" "表格数据设定")
  80.     (DLG_ITEM "boxed_column")
  81.     (DLG_ATT "label" "行列数目设定")
  82.     (DLG_ITEM "popup_list")
  83.     (DLG_ATT "key" "col_qty")
  84.     (DLG_ATT "label" "请选择行数:")
  85.     (DLG_CLOSE)
  86.     (DLG_ITEM "popup_list")
  87.     (DLG_ATT "key" "row_qty")
  88.     (DLG_ATT "label" "请选择列数:")
  89.     (DLG_CLOSE)
  90.     (DLG_CLOSE)
  91.     (DLG_ITEM "toggle")
  92.     (DLG_ATT "label" "定义标题字符串")
  93.     (DLG_ATT "key" "togg")
  94.     (DLG_CLOSE)
  95.     (DLG_ITEM "button")
  96.     (DLG_ATT "key" "get_qty")
  97.     (DLG_ATT "label" "表格数据输入...")
  98.     (DLG_CLOSE)
  99.     (DLG_ITEM "button")
  100.     (DLG_ATT "key" "cancel")
  101.     (DLG_ATT "is_cancel" 'TRUE)
  102.     (DLG_ATT "label" "退出")
  103.     (DLG_CLOSE)
  104.     (DLG_CLOSE)
  105.     (close FD)
  106.     "temp.dcl"
  107.   ) ;_ end of Defun
  108.   (Defun DCL_MATRIX (/ FD)
  109.     (setq FD (open "temp.dcl" "w"))
  110.     (DLG_HEADER 0)
  111. ;;;define Table matrix dialog;;;
  112.     (DLG_DIALOG "dlg_matrix")
  113.     (DLG_ATT "label" "表格矩阵数据输入 (无标题文本)")
  114.     (DLG_ITEM "boxed_column")
  115.     (DLG_ATT "label" "表格矩阵数据输入 (无标题文本)")
  116.     (setq ROW_NDX 1)
  117.     (repeat NO_OF_ROWS
  118.       (DLG_ITEM "row")
  119.       (setq COL_NDX 1)
  120.       (repeat NO_OF_COLS
  121.         (DLG_ITEM "edit_box")
  122.         (DLG_ATT
  123.           "key"
  124.           (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX))
  125.         ) ;_ end of dlg_att
  126.         (DLG_ATT "edit_width" 7)
  127.         (DLG_ATT "edit_limit" 20)
  128.         (DLG_CLOSE)
  129.         (setq COL_NDX (1+ COL_NDX))
  130.       ) ;_ end of repeat
  131.       (DLG_CLOSE)
  132.       (setq ROW_NDX (1+ ROW_NDX))
  133.     ) ;_ end of repeat
  134.     (DLG_CLOSE)
  135.     (DLG_ITEM "row")
  136.     (DLG_ITEM "button")
  137.     (DLG_ATT "key" "do_Table")
  138.     (DLG_ATT "label" "插入表格")
  139.     (DLG_CLOSE)
  140.     (DLG_ITEM "button")
  141.     (DLG_ATT "key" "cancel")
  142.     (DLG_ATT "is_cancel" 'TRUE)
  143.     (DLG_ATT "label" "退出")
  144.     (DLG_CLOSE)
  145.     (DLG_CLOSE)
  146.     (DLG_CLOSE)
  147.     (close FD)
  148.     "temp.dcl"
  149.   ) ;_ end of Defun
  150.   (Defun DCL_MATRIX_HEAD (/ FD)
  151.     (setq FD (open "temp.dcl" "w"))
  152.     (DLG_HEADER 0)
  153. ;;;define Table Matrix_head dialog;;;
  154.     (DLG_DIALOG "dlg_matrix_head")
  155.     (DLG_ATT "label" "表格矩阵数据输入 (含标题文本)")
  156.     (DLG_ITEM "edit_box")
  157.     (DLG_ATT "key" "title")
  158.     (DLG_ATT "label" "表格标题:")
  159.     (DLG_CLOSE)
  160.     (DLG_ITEM "boxed_column")
  161.     (DLG_ATT "label" "表格矩阵数据输入 (含标题文本)")
  162.     (setq ROW_NDX 1)
  163.     (repeat NO_OF_ROWS
  164.       (DLG_ITEM "row")
  165.       (setq COL_NDX 1)
  166.       (repeat NO_OF_COLS
  167.         (DLG_ITEM "edit_box")
  168.         (DLG_ATT
  169.           "key"
  170.           (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX))
  171.         ) ;_ end of dlg_att
  172.         (DLG_ATT "edit_width" 7)
  173.         (DLG_ATT "edit_limit" 20)
  174.         (DLG_CLOSE)
  175.         (setq COL_NDX (1+ COL_NDX))
  176.       ) ;_ end of repeat
  177.       (DLG_CLOSE)
  178.       (setq ROW_NDX (1+ ROW_NDX))
  179.     ) ;_ end of repeat
  180.     (DLG_CLOSE)
  181.     (DLG_ITEM "row")
  182.     (DLG_ITEM "button")
  183.     (DLG_ATT "key" "do_Table")
  184.     (DLG_ATT "label" "插入表格")
  185.     (DLG_CLOSE)
  186.     (DLG_ITEM "button")
  187.     (DLG_ATT "key" "cancel")
  188.     (DLG_ATT "is_cancel" 'TRUE)
  189.     (DLG_ATT "label" "退出")
  190.     (DLG_CLOSE)
  191.     (DLG_CLOSE)
  192.     (DLG_CLOSE)
  193.     (close FD)
  194.     "temp.dcl"
  195.   )
  196. ;;;********************SET UP COLUMN QUANTITY POPUP LIST********************
  197.   (Defun SET_COL ()
  198.     (setq COL_QTY (list "2" "3" "4" "5" "6" "7" "8" "9" "10"))
  199.     (start_list "col_qty")
  200.     (mapcar 'add_list COL_QTY)
  201.     (end_list)
  202.     (if        (not COL_NUM)
  203.       (set_tile "col_qty" "0")
  204.       (set_tile "col_qty" (itoa COL_NUM))
  205.     ) ;_ end of if
  206.   )
  207. ;;;********************GET COLUMN QUANTITY POPUP LIST***********************
  208.   (Defun GET_COL ()
  209.     (setq COL_NUM (atoi (get_tile "col_qty")))
  210.     (setq COL_INPUT (nth COL_NUM COL_QTY))
  211.     (setq NO_OF_COLS (atoi COL_INPUT))
  212.   )
  213. ;;;********************SET UP ROW QUANTITY POPUP LIST********************
  214.   (Defun SET_ROW ()
  215.     (setq ROW_QTY (list "2" "3" "4" "5" "6" "7" "8" "9" "10"))
  216.     (start_list "row_qty")
  217.     (mapcar 'add_list ROW_QTY)
  218.     (end_list)
  219.     (if        (not ROW_NUM)
  220.       (set_tile "row_qty" "0")
  221.       (set_tile "row_qty" (itoa ROW_NUM))
  222.     ) ;_ end of if
  223.   )
  224. ;;;********************GET ROW QUANTITY POPUP LIST***********************
  225.   (Defun GET_ROW ()
  226.     (setq ROW_NUM (atoi (get_tile "row_qty")))
  227.     (setq ROW_INPUT (nth ROW_NUM ROW_QTY))
  228.     (setq NO_OF_ROWS (atoi ROW_INPUT))
  229.   )
  230. ;;;*************GET QUANTITY OF COLUMNS & ROWS FROM POPUP LISTS**********
  231.   (Defun GET_QTY () (GET_COL) (GET_ROW) (setq FLAG 2))
  232. ;;; Utility function to aid in allowing user to input by Columns
  233.   (Defun CHECK_NEXT (REASON KEY LST)
  234.     (if        (= REASON 1)
  235.       (mode_tile (cdr (assoc KEY (eval (read "next_matrix")))) 2)
  236.     ) ;_ end of if
  237.   )
  238. ;;;**SET UP A LIST TO ALLOW THE RETURN KEY TO BE USED (COLUMN INPUT) AS WELL AS TAB KEY FOR (ROW INPUT)**
  239.   (Defun SET_NEXT_MATRIX_ITEM ()
  240.     (setq COL_NDX 1)
  241.     (repeat NO_OF_COLS
  242.       (setq ROW_NDX 1)
  243.       (setq
  244.         NEXT_MATRIX
  245.          (append
  246.            NEXT_MATRIX
  247.            (list
  248.              (cons
  249.                (strcat
  250.                  "row"
  251.                  (itoa ROW_NDX)
  252.                  "col"
  253.                  (itoa COL_NDX)
  254.                ) ;_ end of strcat
  255.                (strcat
  256.                  "row"
  257.                  (itoa (1+ ROW_NDX))
  258.                  "col"
  259.                  (itoa COL_NDX)
  260.                ) ;_ end of strcat
  261.              ) ;_ end of cons
  262.            ) ;_ end of list
  263.          ) ;_ end of append
  264.       ) ;_ end of setq
  265.       (while (< ROW_NDX NO_OF_ROWS)
  266.         (setq ROW_NDX (1+ ROW_NDX))
  267.         (setq
  268.           NEXT_MATRIX
  269.            (append
  270.              NEXT_MATRIX
  271.              (list
  272.                (cons
  273.                  (strcat
  274.                    "row"
  275.                    (itoa ROW_NDX)
  276.                    "col"
  277.                    (itoa COL_NDX)
  278.                  ) ;_ end of strcat
  279.                  (strcat
  280.                    "row"
  281.                    (itoa (1+ ROW_NDX))
  282.                    "col"
  283.                    (itoa COL_NDX)
  284.                  ) ;_ end of strcat
  285.                ) ;_ end of cons
  286.              ) ;_ end of list
  287.            ) ;_ end of append
  288.         ) ;_ end of setq
  289.       ) ;_ end of while
  290.       (setq COL_NDX (1+ COL_NDX))
  291.     ) ;_ end of repeat
  292.   ) ;_ end of Defun
  293.   (Defun TOG_ASSOC ()
  294.     (if        (= TOG_VALUE "1")
  295.       (setq INCL "yes")
  296.     ) ;_ end of if
  297.     (if        (= TOG_VALUE "0")
  298.       (setq INCL "no")
  299.     ) ;_ end of if
  300.   ) ;_ end of Defun
  301. ;;;;;MAIN DIALOG CONTROL FUNCTIONS;;;;
  302. ;;; Loads the Main Dialog and Removes it when selections (OR) ok/cancel are pushed ;;;
  303.   (Defun DLG_MAIN (/ FLAG)
  304.     (if        (< (setq DCL_ID (load_dialog "temp.dcl")) 0)
  305.       (exit)
  306.     ) ;_ end of if
  307.     (close (open "temp.dcl" "w"))
  308.     (if        (not (new_dialog "dlg_main" *TABLEID*))
  309.       (exit)
  310.     ) ;_ end of if
  311.     (SET_COL)
  312.     (SET_ROW)
  313.     (action_tile "togg" "(setq tog_value $value)(tog_assoc)")
  314.     (action_tile "col_qty" "(get_col)")
  315.     (action_tile "row_qty" "(get_row)")
  316.     (action_tile
  317.       "get_qty"
  318.       "(tog_assoc)(get_qty)(done_dialog 1)"
  319.     )
  320.     (action_tile "cancel" "(done_dialog 0)")
  321.     (start_dialog)
  322.     (if        (= FLAG 2)
  323.       (DELETE_TEMP_DCL)
  324.     ) ;_ end of if
  325.     (setq FD (open "symtos.txt" "w"))
  326.     (princ "" FD)
  327.     (close FD)
  328.     (princ)
  329.   ) ;_ end of Defun
  330.   (Defun DELETE_TEMP_DCL (/ *TABLEID*)        ;delete
  331.     (if        (not *TABLEID*)
  332. ;;; first time thru
  333.       (progn
  334.         (if (= INCL "no")
  335.           (DCL_MATRIX)
  336.         ) ;_ end of if
  337.         (if (= INCL "yes")
  338.           (DCL_MATRIX_HEAD)
  339.         ) ;_ end of if
  340.         (if (< (setq *TABLEID* (load_dialog "temp.dcl")) 0)
  341.           (*ERROR* "对话框输入数据错误")
  342.         ) ;_ end of if
  343.         (if (= INCL "no")
  344.           (DLG_MATRIX)
  345.         ) ;_ end of if
  346.         (if (= INCL "yes")
  347.           (DLG_MATRIX_HEAD)
  348.         ) ;_ end of if
  349.       ) ;_ end of progn
  350.     ) ;_ end of if
  351.   ) ;_ end of Defun
  352.   (Defun DLG_MATRIX (/ FLAG)
  353.     (if        (< (setq DCL_ID (load_dialog "temp.dcl")) 0)
  354.       (exit)
  355.     ) ;_ end of if
  356.     (close (open "temp.dcl" "w"))
  357.     (if        (not (new_dialog "dlg_matrix" *TABLEID*))
  358.       (exit)
  359.     ) ;_ end of if
  360.     (SET_NEXT_MATRIX_ITEM)
  361.     (foreach
  362.               A
  363.                NEXT_MATRIX
  364.       (action_tile (car A) "(check_next $reason $key 0)")
  365.     ) ;_ end of foreach
  366.     (action_tile "do_Table" "(get_matrix) (done_dialog 1)")
  367.     (action_tile "cancel" "(done_dialog 0)")
  368.     (start_dialog)
  369.     (if        (= FLAG 1)
  370.       (DRAW_TABLE)
  371.     ) ;_ end of if
  372.     (unload_dialog DCL_ID)
  373.   ) ;_ end of Defun
  374.   (Defun
  375.             DLG_MATRIX_HEAD
  376.                            (/ FLAG)
  377.     (if        (< (setq DCL_ID (load_dialog "temp.dcl")) 0)
  378.       (exit)
  379.     ) ;_ end of if
  380.     (close (open "temp.dcl" "w"))
  381.     (if        (not (new_dialog "dlg_matrix_head" *TABLEID*))
  382.       (exit)
  383.     ) ;_ end of if
  384.     (SET_NEXT_MATRIX_ITEM)
  385.     (foreach A NEXT_MATRIX
  386.       (action_tile (car A) "(check_next $reason $key 0)")
  387.     ) ;_ end of foreach
  388.     (action_tile "do_Table" "(get_matrix_head) (done_dialog 1)")
  389.     (action_tile "cancel" "(done_dialog 0)")
  390.     (start_dialog)
  391.     (if        (= FLAG 1)
  392.       (DRAW_TABLE_HEAD)
  393.     ) ;_ end of if
  394.     (unload_dialog DCL_ID)
  395.   ) ;_ end of Defun
  396.   (Defun GET_MATRIX ()
  397.     (terpri)
  398.     (princ "读取矩阵输入数据...")
  399.     (setq COL_NDX 1)
  400.     (setq ROW_NDX 1)
  401.     (repeat NO_OF_ROWS
  402.       (setq COL_NDX 1)
  403.       (repeat NO_OF_COLS
  404.         (set
  405.           (read (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX)))
  406.           (get_tile (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX))
  407.           )
  408.         ) ;_ end of set
  409.         (setq COL_NDX (1+ COL_NDX))
  410.       ) ;_ end of repeat
  411.       (setq ROW_NDX (1+ ROW_NDX))
  412.     ) ;_ end of repeat
  413.     (setq FLAG 1)
  414.   ) ;_ end of Defun
  415.   (Defun GET_MATRIX_HEAD ()
  416.     (terpri)
  417.     (princ "读取矩阵输入数据...")
  418.     (setq TITLE (get_tile "title"))
  419.     (setq COL_NDX 1)
  420.     (setq ROW_NDX 1)
  421.     (repeat NO_OF_ROWS
  422.       (setq COL_NDX 1)
  423.       (repeat NO_OF_COLS
  424.         (set
  425.           (read (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX)))
  426.           (get_tile (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX))
  427.           )
  428.         ) ;_ end of set
  429.         (setq COL_NDX (1+ COL_NDX))
  430.       ) ;_ end of repeat
  431.       (setq ROW_NDX (1+ ROW_NDX))
  432.     ) ;_ end of repeat
  433.     (setq FLAG 1)
  434.   ) ;_ end of Defun
  435.   (Defun DRAW_TABLE ()
  436.     (setvar "cmdecho" 0)
  437.     (setq DS          (getvar "dimscale")
  438.           OSMODE
  439.                   (getvar "osmode")
  440.           CECOLOR
  441.                   (getvar "cecolor")
  442.           CLAYER
  443.                   (getvar "clayer")
  444.           SCALE
  445.                   (getvar "dimscale")
  446.     ) ;_ end of setq
  447.     (if        (= (tblsearch "layer" "TABLE") NIL)
  448.       (command "layer" "make" "TABLE" "color" "red" "" "set" "TABLE" "")
  449.     ) ;_ end of if
  450.     (command "layer" "set" "TABLE" "")
  451.     (if        (= (tblsearch "style" "romans") NIL)
  452.       (command "style" "romans" "romans.shx" "" "" "" "" "" "")
  453.     ) ;_ end of if
  454.     (if        (= (tblsearch "style" "romand") NIL)
  455.       (command "style" "romand" "romand.shx" "" "" "" "" "" "")
  456.     ) ;_ end of if
  457.     (setq SIZE (* (getvar "dimscale") (getvar "dimtxt")))
  458.     (setq HALFSIZE (* SIZE 0.5))
  459.     (setq TITLESIZE (* SIZE 1.5))
  460.     (setq SP (getpoint "\n 请点取表格左上角位置: "))
  461.     (setvar "osmode" 0)
  462.     (setq TABLE_WIDTH 0)
  463.     (setq COL_NDX 1)
  464.     (repeat NO_OF_COLS
  465.       (setq ROW_NDX 1)
  466.       (setq COL_WIDTH 0)
  467.       (while
  468.         (/= (eval
  469.               (read (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX)))
  470.             ) ;_ end of eval
  471.             NIL
  472.         ) ;_ end of /=
  473.          (progn
  474.            (setq
  475.              ENTRY_WIDTH
  476.               (strlen
  477.                 (eval
  478.                   (read
  479.                     (strcat
  480.                       "row"
  481.                       (itoa ROW_NDX)
  482.                       "col"
  483.                       (itoa COL_NDX)
  484.                     ) ;_ end of strcat
  485.                   ) ;_ end of read
  486.                 ) ;_ end of eval
  487.               ) ;_ end of strlen
  488.            ) ;_ end of setq
  489.            (if (> ENTRY_WIDTH COL_WIDTH)
  490.              (setq COL_WIDTH ENTRY_WIDTH)
  491.            ) ;_ end of if
  492.            (setq ROW_NDX (1+ ROW_NDX))
  493.          ) ;_ end of progn
  494.       ) ;_ end of while
  495.       (setq COL_WIDTH (+ COL_WIDTH 1.0))
  496.       (set (read (strcat "column" (itoa COL_NDX))) COL_WIDTH)
  497.       (setq TABLE_WIDTH (+ TABLE_WIDTH COL_WIDTH))
  498.       (setq COL_NDX (1+ COL_NDX))
  499.     ) ;_ end of repeat
  500.     (setq TOTAL_WIDTH (* SIZE TABLE_WIDTH))
  501.     (setq TOTAL_HEIGHT (* (* SIZE 2.0) NO_OF_ROWS))
  502.     (setq PT1 (list (+ (car SP) TOTAL_WIDTH) (cadr SP) 0.0))
  503.     (setq PT2 (list (+ (car SP) TOTAL_WIDTH)
  504.                     (- (cadr SP) TOTAL_HEIGHT)
  505.                     0.0
  506.               )
  507.     ) ;_ end of setq
  508.     (setq PT3 (list (car SP) (- (cadr SP) TOTAL_HEIGHT) 0.0))
  509.     (setq TEMP (getvar "plinewid"))
  510.     (setvar "plinewid" 0.015)
  511.     (command "pline" SP PT1 PT2 PT3 "close")
  512. ;;;;Draw horizontal lines in Table;;;;
  513.     (setq ROW_NDX 1)
  514.     (repeat (- NO_OF_ROWS 1)
  515.       (setq
  516.         LP (list (car SP) (- (cadr SP) (* (* SIZE 2.0) ROW_NDX)) 0.0)
  517.       ) ;_ end of setq
  518.       (setq
  519.         RP (list (car PT1) (- (cadr SP) (* (* SIZE 2.0) ROW_NDX)) 0.0)
  520.       ) ;_ end of setq
  521.       (command "line" LP RP "")
  522.       (setq ROW_NDX (1+ ROW_NDX))
  523.     ) ;_ end of repeat
  524. ;;;;Draw vertical lines in Table;;;;
  525.     (setq NDX 1)
  526.     (repeat (- NO_OF_COLS 1)
  527.       (if (= NDX 1)
  528.         (setq TP (list (+ (car SP) (* COLUMN1 SIZE)) (cadr SP) 0.0))
  529.         (setq
  530.           TP (list
  531.                (+ (car (getvar "lastpoint"))
  532.                   (* (eval (read (strcat "column" (itoa NDX)))) SIZE)
  533.                ) ;_ end of +
  534.                (cadr SP)
  535.                0.0
  536.              ) ;_ end of list
  537.         ) ;_ end of setq
  538.       ) ;_ end of if
  539.       (if (= NDX 1)
  540.         (setq BP (list (+ (car SP) (* COLUMN1 SIZE)) (cadr PT3) 0.0))
  541.         (setq
  542.           BP (list
  543.                (+ (car (getvar "lastpoint"))
  544.                   (* (eval (read (strcat "column" (itoa NDX)))) SIZE)
  545.                ) ;_ end of +
  546.                (cadr PT3)
  547.                0.0
  548.              ) ;_ end of list
  549.         ) ;_ end of setq
  550.       ) ;_ end of if
  551.       (command "line" TP BP "")
  552.       (setq NDX (1+ NDX))
  553.     ) ;_ end of repeat
  554.     (setvar "plinewid" TEMP)
  555.     (setvar "textstyle" "romans")
  556. ;;;;Place matrix text;;;;
  557.     (setq COL_NDX 1)
  558.     (setq ROW_NDX 1)
  559.     (repeat NO_OF_COLS
  560.       (if (= COL_NDX 1)
  561.         (setq
  562.           HP (+        (car SP)
  563.                 (* (eval (read (strcat "column" (itoa COL_NDX))))
  564.                    HALFSIZE
  565.                 ) ;_ end of *
  566.              ) ;_ end of +
  567.         ) ;_ end of setq
  568.         (setq
  569.           HP
  570.            (+
  571.              HP
  572.              (+        (* (eval (read (strcat "column" (itoa (- COL_NDX 1)))))
  573.                    HALFSIZE
  574.                 ) ;_ end of *
  575.                 (* (eval (read (strcat "column" (itoa COL_NDX))))
  576.                    HALFSIZE
  577.                 ) ;_ end of *
  578.              ) ;_ end of +
  579.            ) ;_ end of +
  580.         ) ;_ end of setq
  581.       ) ;_ end of if
  582.       (setq ROW_NDX 1)
  583.       (repeat NO_OF_ROWS
  584.         (if (= ROW_NDX 1)
  585.           (setq VP (- (cadr SP) (* SIZE 1)))
  586.           (setq VP (- VP (* SIZE 2)))
  587.         ) ;_ end of if
  588.         (setq LOC (list HP VP 0.0))
  589.         (command
  590.           "text"
  591.           "j"
  592.           "mc"
  593.           LOC
  594.           SIZE
  595.           "0"
  596.           (eval
  597.             (read (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX)))
  598.           ) ;_ end of eval
  599.         ) ;_ end of command
  600.         (setq ROW_NDX (1+ ROW_NDX))
  601.       ) ;_ end of repeat
  602.       (setq COL_NDX (1+ COL_NDX))
  603.     ) ;_ end of repeat
  604. ;;;;Delete Matrix Variables
  605.     (setq CNT 1)
  606.     (while (<= CNT NDX)
  607.       (set (read (strcat "column" (itoa CNT))) NIL)
  608.       (setq CNT (1+ CNT))
  609.     ) ;_ end of while
  610.     (setq COL_NDX 1)
  611.     (setq ROW_NDX 1)
  612.     (repeat NO_OF_COLS
  613.       (if (= COL_NDX 1)
  614.         (set (read (strcat "column" (itoa COL_NDX))) NIL)
  615.         (set (read (strcat "column" (itoa (- COL_NDX 1)))) NIL)
  616.       ) ;_ end of if
  617.       (setq ROW_NDX 1)
  618.       (repeat NO_OF_ROWS
  619.         (set
  620.           (read (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX)))
  621.           NIL
  622.         ) ;_ end of set
  623.         (setq ROW_NDX (1+ ROW_NDX))
  624.       ) ;_ end of repeat
  625.       (setq COL_NDX (1+ COL_NDX))
  626.     ) ;_ end of repeat
  627.     (setvar "osmode" OSMODE)
  628.     (setvar "cecolor" CECOLOR)
  629.     (setvar "clayer" CLAYER)
  630.   ) ;_ end of Defun
  631.   (Defun DRAW_TABLE_HEAD ()
  632.     (setvar "cmdecho" 0)
  633.     (setq DS          (getvar "dimscale")
  634.           OSMODE
  635.                   (getvar "osmode")
  636.           CECOLOR
  637.                   (getvar "cecolor")
  638.           CLAYER
  639.                   (getvar "clayer")
  640.           SCALE
  641.                   (getvar "dimscale")
  642.     ) ;_ end of setq
  643.     (if        (= (tblsearch "layer" "TABLE") NIL)
  644.       (command "layer" "make" "TABLE" "color" "red" "" "set" "TABLE" "")
  645.     ) ;_ end of if
  646.     (command "layer" "set" "TABLE" "")
  647.     (if        (= (tblsearch "style" "romans") NIL)
  648.       (command "style" "romans" "romans.shx" "" "" "" "" "" "")
  649.     ) ;_ end of if
  650.     (if        (= (tblsearch "style" "romand") NIL)
  651.       (command "style" "romand" "romand.shx" "" "" "" "" "" "")
  652.     ) ;_ end of if
  653.     (setq SIZE (* (getvar "dimscale") (getvar "dimtxt")))
  654.     (setq HALFSIZE (* SIZE 0.5))
  655.     (setq TITLESIZE (* SIZE 1.5))
  656.     (setq SP (getpoint "\n 请点取表格左上角位置: "))
  657.     (setvar "osmode" 0)
  658.     (setq TITLE_WIDTH (strlen TITLE))
  659.     (setq TABLE_WIDTH 0)
  660.     (setq COL_NDX 1)
  661.     (repeat NO_OF_COLS
  662.       (setq ROW_NDX 1)
  663.       (setq COL_WIDTH 0)
  664.       (while
  665.         (/= (eval
  666.               (read (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX)))
  667.             ) ;_ end of eval
  668.             NIL
  669.         ) ;_ end of /=
  670.          (progn
  671.            (setq
  672.              ENTRY_WIDTH
  673.               (strlen
  674.                 (eval
  675.                   (read
  676.                     (strcat
  677.                       "row"
  678.                       (itoa ROW_NDX)
  679.                       "col"
  680.                       (itoa COL_NDX)
  681.                     ) ;_ end of strcat
  682.                   ) ;_ end of read
  683.                 ) ;_ end of eval
  684.               ) ;_ end of strlen
  685.            ) ;_ end of setq
  686.            (if (> ENTRY_WIDTH COL_WIDTH)
  687.              (setq COL_WIDTH ENTRY_WIDTH)
  688.            ) ;_ end of if
  689.            (setq ROW_NDX (1+ ROW_NDX))
  690.          ) ;_ end of progn
  691.       ) ;_ end of while
  692.       (setq COL_WIDTH (+ COL_WIDTH 1.0))
  693.       (set (read (strcat "column" (itoa COL_NDX))) COL_WIDTH)
  694.       (setq TABLE_WIDTH (+ TABLE_WIDTH COL_WIDTH))
  695.       (setq COL_NDX (1+ COL_NDX))
  696.     ) ;_ end of repeat
  697. ;;;Determine which is Greater (The Title Width) or (The Sum of all the Column Widths);;;
  698.     (setq OVERAGE (/ (- (* TITLE_WIDTH 1.5) TABLE_WIDTH) NO_OF_COLS))
  699.     (if        (or (= OVERAGE 0) (> OVERAGE 0))
  700.       (progn
  701.         (setq TABLE_WIDTH 0)
  702.         (setq OVERAGE (1+ (fix OVERAGE)))
  703.         (setq COL_NDX 1)
  704.         (repeat        NO_OF_COLS
  705.           (while
  706.             (/= (eval (read (strcat "column" (itoa COL_NDX)))) NIL)
  707.              (progn
  708.                (set
  709.                  (read (strcat "column" (itoa COL_NDX)))
  710.                  (+ (eval (read (strcat "column" (itoa COL_NDX))))
  711.                     OVERAGE
  712.                  ) ;_ end of +
  713.                ) ;_ end of set
  714.                (setq
  715.                  COL_WIDTH
  716.                   (eval (read (strcat "column" (itoa COL_NDX))))
  717.                ) ;_ end of setq
  718.                (setq TABLE_WIDTH (+ TABLE_WIDTH COL_WIDTH))
  719.                (setq COL_NDX (1+ COL_NDX))
  720.              ) ;_ end of progn
  721.           ) ;_ end of while
  722.         ) ;_ end of repeat
  723.       ) ;_ end of progn
  724.     ) ;_ end of if
  725.     (setq TOTAL_WIDTH (* SIZE TABLE_WIDTH))
  726.     (setq
  727.       TOTAL_HEIGHT
  728.        (+ (* TITLESIZE 2.0) (* (* NO_OF_ROWS 2.0) SIZE))
  729.     ) ;_ end of setq
  730.     (setq PT1 (list (+ (car SP) TOTAL_WIDTH) (cadr SP) 0.0))
  731.     (setq
  732.       PT2
  733.        (list (+ (car SP) TOTAL_WIDTH)
  734.              (- (cadr SP) TOTAL_HEIGHT)
  735.              0.0
  736.        )
  737.     ) ;_ end of setq
  738.     (setq PT3 (list (car SP) (- (cadr SP) TOTAL_HEIGHT) 0.0))
  739.     (setq TEMP (getvar "plinewid"))
  740.     (setvar "plinewid" 0.011)
  741.     (if        (= (tblsearch "layer" "TABLE") NIL)
  742.       (command "layer" "make" "TABLE" "color" "red" "" "set" "TABLE" "")
  743.     ) ;_ end of if
  744.     (command "layer" "set" "TABLE" "")
  745.     (if        (= (tblsearch "style" "romans") NIL)
  746.       (command "style" "romans" "romans.shx" "" "" "" "" "" "")
  747.     ) ;_ end of if
  748.     (if        (= (tblsearch "style" "romand") NIL)
  749.       (command "style" "romand" "romand.shx" "" "" "" "" "" "")
  750.     ) ;_ end of if
  751.     (command "pline" SP PT1 PT2 PT3 "close")
  752. ;;;;Draw horizontal lines in Table;;;;
  753.     (setq ROW_NDX 1)
  754.     (repeat NO_OF_ROWS
  755.       (setq
  756.         LP (list
  757.              (car SP)
  758.              (- (cadr SP) (+ (* (* SIZE 2.0) ROW_NDX)) SIZE)
  759.              0.0
  760.            ) ;_ end of list
  761.       ) ;_ end of setq
  762.       (setq
  763.         RP (list
  764.              (car PT1)
  765.              (- (cadr SP) (+ (* (* SIZE 2.0) ROW_NDX)) SIZE)
  766.              0.0
  767.            ) ;_ end of list
  768.       ) ;_ end of setq
  769.       (command "line" LP RP "")
  770.       (setq ROW_NDX (1+ ROW_NDX))
  771.     ) ;_ end of repeat
  772. ;;;;Draw vertical lines in Table;;;;
  773.     (setq NDX 1)
  774.     (repeat (- NO_OF_COLS 1)
  775.       (if (= NDX 1)
  776.         (setq
  777.           TP (list
  778.                (+ (car SP) (* COLUMN1 SIZE))
  779.                (- (cadr SP) (* TITLESIZE 2.0))
  780.                0.0
  781.              ) ;_ end of list
  782.         ) ;_ end of setq
  783.         (setq
  784.           TP (list
  785.                (+ (car (getvar "lastpoint"))
  786.                   (* (eval (read (strcat "column" (itoa NDX)))) SIZE)
  787.                ) ;_ end of +
  788.                (- (cadr SP) (* TITLESIZE 2.0))
  789.                0.0
  790.              ) ;_ end of list
  791.         ) ;_ end of setq
  792.       ) ;_ end of if
  793.       (if (= NDX 1)
  794.         (setq BP (list (+ (car SP) (* COLUMN1 SIZE)) (cadr PT3) 0.0))
  795.         (setq
  796.           BP (list
  797.                (+ (car (getvar "lastpoint"))
  798.                   (* (eval (read (strcat "column" (itoa NDX)))) SIZE)
  799.                ) ;_ end of +
  800.                (cadr PT3)
  801.                0.0
  802.              ) ;_ end of list
  803.         ) ;_ end of setq
  804.       ) ;_ end of if
  805.       (command "line" TP BP "")
  806.       (setq NDX (1+ NDX))
  807.     ) ;_ end of repeat
  808.     (setvar "plinewid" TEMP)
  809. ;;;;Place Table Title text;;;;
  810.     (setq
  811.       TITLE_LOC
  812.        (list
  813.          (+ (car SP) (* TOTAL_WIDTH 0.5))
  814.          (- (cadr SP) TITLESIZE)
  815.        ) ;_ end of list
  816.     ) ;_ end of setq
  817.     (setvar "textstyle" "romand")
  818.     (command "text" "j" "mc" TITLE_LOC TITLESIZE "0" TITLE)
  819.     (setvar "textstyle" "romans")
  820. ;;;;Place matrix text;;;;
  821.     (setq COL_NDX 1)
  822.     (setq ROW_NDX 1)
  823.     (repeat NO_OF_COLS
  824.       (if (= COL_NDX 1)
  825.         (setq
  826.           HP (+        (car SP)
  827.                 (* (eval (read (strcat "column" (itoa COL_NDX))))
  828.                    HALFSIZE
  829.                 ) ;_ end of *
  830.              ) ;_ end of +
  831.         ) ;_ end of setq
  832.         (setq
  833.           HP
  834.            (+
  835.              HP
  836.              (+        (* (eval (read (strcat "column" (itoa (- COL_NDX 1)))))
  837.                    HALFSIZE
  838.                 ) ;_ end of *
  839.                 (* (eval (read (strcat "column" (itoa COL_NDX))))
  840.                    HALFSIZE
  841.                 ) ;_ end of *
  842.              ) ;_ end of +
  843.            ) ;_ end of +
  844.         ) ;_ end of setq
  845.       ) ;_ end of if
  846.       (setq ROW_NDX 1)
  847.       (repeat NO_OF_ROWS
  848.         (if (= ROW_NDX 1)
  849.           (setq VP (- (cadr SP) (* SIZE 4)))
  850.           (setq VP (- VP (* SIZE 2)))
  851.         ) ;_ end of if
  852.         (setq LOC (list HP VP 0.0))
  853.         (command
  854.           "text"
  855.           "j"
  856.           "mc"
  857.           LOC
  858.           SIZE
  859.           "0"
  860.           (eval
  861.             (read (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX)))
  862.           ) ;_ end of eval
  863.         ) ;_ end of command
  864.         (setq ROW_NDX (1+ ROW_NDX))
  865.       ) ;_ end of repeat
  866.       (setq COL_NDX (1+ COL_NDX))
  867.     ) ;_ end of repeat
  868. ;;;;Delete Matrix Variables
  869.     (setq CNT 1)
  870.     (while (<= CNT NDX)
  871.       (set (read (strcat "column" (itoa CNT))) NIL)
  872.       (setq CNT (1+ CNT))
  873.     ) ;_ end of while
  874.     (setq COL_NDX 1)
  875.     (setq ROW_NDX 1)
  876.     (repeat NO_OF_COLS
  877.       (if (= COL_NDX 1)
  878.         (set (read (strcat "column" (itoa COL_NDX))) NIL)
  879.         (set (read (strcat "column" (itoa (- COL_NDX 1)))) NIL)
  880.       ) ;_ end of if
  881.       (setq ROW_NDX 1)
  882.       (repeat NO_OF_ROWS
  883.         (set
  884.           (read (strcat "row" (itoa ROW_NDX) "col" (itoa COL_NDX)))
  885.           NIL
  886.         ) ;_ end of set
  887.         (setq ROW_NDX (1+ ROW_NDX))
  888.       ) ;_ end of repeat
  889.       (setq COL_NDX (1+ COL_NDX))
  890.     ) ;_ end of repeat
  891.     (setvar "osmode" OSMODE)
  892.     (setvar "cecolor" CECOLOR)
  893.     (setvar "clayer" CLAYER)
  894.   ) ;_ end of Defun
  895. ;;; initialize value settings ;;;
  896.   (setq
  897.     TOG_VALUE "0"
  898.     OL              (getvar "clayer")
  899.     OS              (getvar "textstyle")
  900.     OC              (getvar "cmdecho")
  901.   ) ;_ end of setq
  902. ;;; define error routine ;;;
  903.   (setq TABLE_ERR *ERROR*)
  904.   (Defun *ERROR* (MSG)
  905.     (princ MSG)
  906.     (setq *ERROR* TABLE_ERR)
  907.     (if        OL
  908.       (setvar "clayer" OL)
  909.     ) ;_ end of if
  910.     (if        OS
  911.       (setvar "textstyle" OS)
  912.     ) ;_ end of if
  913.     (if        OC
  914.       (setvar "cmdecho" OC)
  915.     ) ;_ end of if
  916.     (setq FD (open "symtos.txt" "w"))
  917.     (princ "" FD)
  918.     (close FD)
  919.     (princ)
  920.   ) ;_ end of Defun
  921. ;;; Perform creation of dialog, input dialog & set global Handle (*Tableid*) ;;;
  922.   (if (not *TABLEID*)
  923. ;;; first time thru
  924.     (progn
  925.       (DCL_TEMP)
  926.       (if (< (setq *TABLEID* (load_dialog "temp.dcl")) 0)
  927.         (*ERROR* "对话框数据错误")
  928.       ) ;_ end of if
  929.     ) ;_ end of progn
  930.   ) ;_ end of if
  931.   (DLG_MAIN)
  932. ;;;   restore error handler and exit   ;;;
  933.   (terpri)
  934. ) ;_ end of Defun
  935. (princ)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2014-3-19 19:43:52 | 显示全部楼层
怎么没有人顶啊
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 22个

财富等级: 恭喜发财

发表于 2014-4-1 13:00:43 | 显示全部楼层
这个不错。就是表格的宽度没找到在哪儿修改的。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 329个

财富等级: 日进斗金

发表于 2014-7-29 15:08:28 | 显示全部楼层
表格绘制,正在学这个
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 217个

财富等级: 日进斗金

发表于 2014-9-24 12:32:11 | 显示全部楼层
路過看看:D
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复

使用道具 举报

发表于 2019-10-31 17:33:40 | 显示全部楼层
支持点赞!!!!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-23 10:30 , Processed in 0.206896 second(s), 43 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表