明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1610|回复: 5

如何在程序运算时实现进度表??

[复制链接]
发表于 2008-7-1 22:18:00 | 显示全部楼层 |阅读模式

如题:

如何在程序运算过程中命令行显示进度条:"0%,5%,10%,15%,%20,25%..."

或者象CAD中执行"RENDER"(渲染)时命令行中显示:类似与孙大圣手中的"金箍棒"一样,一直转圈圈呢

 楼主| 发表于 2008-7-4 23:16:00 | 显示全部楼层

有人给我贴了个以下的函数,可是不知道怎么用,有哪位兄弟可以帮忙编个例子,谢谢了

;;一个在状态条显示处理进度的函数
;; k 数 l 长度
(defun xd-pross (k l)
(grtext -2
(strcat "已完成 "
(rtos (/ (* 100.0 k) l)
2
0
)
"%...."
)
)
)

发表于 2008-7-5 10:09:00 | 显示全部楼层

这是另一位大虾编写的,提供参考。


(defun C:dcltut (/ loopmax dcltut_dat)
 (setq dcltut_dat (load_dialog "dcltut.dcl"))
 (new_dialog "dcltut" dcltut_dat)
 (if (null loopmax)(setq loopmax 100))
 (setq fillx (dimx_tile "progbar"))
 (setq filly (dimy_tile "progbar"))
 (start_image "progbar")
 (fill_image 0 0 fillx filly -15)
 (end_image)

 (set_tile "max" (itoa loopmax))
 (action_tile "start" "(loopfunc)")
 (action_tile "ok" "(done_dialog)")
 (action_tile "cnacel" "(done_dialog)")
 (start_dialog)
 (UNLOAD_DIALOG dcltut_dat)
)
 


(defun loopfunc (/ fillx filly loopfunc loopmax loop-counter)
 (setq fillx (dimx_tile "progbar"))
 (setq filly (dimy_tile "progbar"))
 (start_image "progbar")
 (fill_image 0 0 fillx filly -15)
 (end_image)
 (setq loop-counter 0)
 (setq loopmax (atoi (get_tile "max")))
 (while (<= loop-counter loopmax)
  (start_image "progbar")
  (fill_image 0 0 (/ (* loop-counter fillx) loopmax) filly 5)
  (end_image)
  (set_tile "error" (rtos loop-counter))
  (setq loop-counter (1+ loop-counter))
 )
)
 

dcltut    : dialog {
 spacer_1;
     fixed_width = true;
           label = "DCL 滚动条";
             key = "br-label";
       : row {
         : button {
           key      = "start";
           label    = "&Start";
         }
         : edit_box {
           key      = "max";
           label    = "&Max:";
         }
       }
       : image {
         key    = "progbar";
   fixed_width  = 50;
         height = 1;
       }
          : errtile {
            label = "";
              key = "error";
            width = 26;
         }
           : button {
             label = "&OK";
               key = "ok";
        is_default = true;
           }
}
 

发表于 2008-7-5 10:38:00 | 显示全部楼层
linhui12发表于2008-7-4 23:16:00有人给我贴了个以下的函数,可是不知道怎么用,有哪位兄弟可以帮忙编个例子,谢谢了;;一个在状态条显示处理进度的函数;; k 数 l 长度(defun xd-pross (k l)(grtext -2(strcat \"已完成 \"(rtos (/

(defun test(nn / k)
  (setq k 0)
  (repeat nn
    (xd-pross k nn)
    (setq k (1+ k))
    (command "delay" 100)
    )
  (princ)
  )

 楼主| 发表于 2008-7-5 18:12:00 | 显示全部楼层

谢谢楼上二位兄弟的回复,可我刚刚试了一下,二位的方案都不能执行啊,谁能帮忙找找原因.谢谢

发表于 2008-7-5 18:25:00 | 显示全部楼层

(test 100)

或(test 200)

这个只是测试,在程序中你要用(xd-pross k nn),总数为NN,K为每一步的值

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-9-21 04:14 , Processed in 0.148872 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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