Author Topic: Progress Bar  (Read 14918 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Progress Bar
« Reply #30 on: January 28, 2016, 02:53:14 PM »
I scanned over 5000 dwgs today (via objectdbx). AutoCAD didn't "ghost" once.

Using this simple function:

Code: [Select]
(defun MP:Echo ( x / cmdecho millisecs ceiling )

    (cond
        (   (null (setq ceiling 2000 millisecs (getvar 'millisecs)))
        )
        (   (/= 'int (type *MP:Echo:MilliSecs*))
            (setq *MP:Echo:MilliSecs* millisecs)
        )
        (   (< ceiling (- millisecs *MP:Echo:MilliSecs*))
            (setq cmdecho (getvar 'cmdecho))
            (setvar 'cmdecho 0)
            (vl-cmdf ".delay" 0)
            (setvar 'cmdecho cmdecho)
            (setq *MP:Echo:MilliSecs* millisecs)
        )
    )

    (if (eq 'str (type x))
        (setvar 'modemacro (vl-string-trim "\n\r\t" x))
    )

    (princ x)

    (princ)

)

i.e.

Code: [Select]
(progn
    (foreach file file_list
        (MP:Echo (strcat "\nProcessing [" (vl-filename-base file) ".dwg ..."))
        (MP:AbuseDwgViaObjectDBX file report_handle)
        ;;  ... yada ad infinitum ...
    )
    (MP:Echo "\nFinito")
)

If one just wanted to use MP:Echo as a "DoEvents" type function merely call it with a nil, i.e. (MP:Echo nil).

Cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Progress Bar
« Reply #31 on: January 28, 2016, 03:07:51 PM »
Also (command "_.delay" ... ) might be worth a shot.

I guess it works then  :lol:

GDF

  • Water Moccasin
  • Posts: 2081
Re: Progress Bar
« Reply #32 on: January 28, 2016, 08:26:27 PM »
example:
(ACET-UI-PROGRESS-INIT
           "Please Wait while the Program is Running"
           (length DwgList))

(ACET-UI-PROGRESS-SAFE n)
(setq n (+ n 1))
(ACET-UI-PROGRESS-DONE)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Progress Bar
« Reply #33 on: June 30, 2016, 03:24:22 PM »
I guess it works then  :lol:

Sorry -- I missed this post -- it does indeed. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Progress Bar
« Reply #34 on: June 30, 2016, 07:08:06 PM »
 :-)

mailmaverick

  • Bull Frog
  • Posts: 494
Re: Progress Bar
« Reply #35 on: July 05, 2016, 02:59:04 PM »
Out of  (command "_.delay" 0) and (MP:Echo nil), which is better to use ?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Progress Bar
« Reply #36 on: July 05, 2016, 07:11:26 PM »
(command "_.delay" 0)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Sam

  • Bull Frog
  • Posts: 201
Re: Progress Bar
« Reply #37 on: July 06, 2016, 06:32:40 AM »
this is chinese version
author :- lgx
Code: [Select]
(defun progress_lgx(current_pcs tatoal current1_pcs tatoal1 / lgx_screenmin_point lgx_screenmax_point width-x_lgx
        height-y_lgx half-y_lgx grve_lgx min-x_lgx max-x_lgx y_zl_lgx x_zl_lgx)
;;;By: Liu new
(redraw)
(setq lgx_screenmin_point(list (- (car (getvar "viewctr")) (/ (*(/ (getvar "viewsize") (cadr (getvar "screensize"))) (car (getvar "screensize"))) 2))
         (- (cadr (getvar "viewctr")) (/ (getvar "viewsize") 2))))
(setq lgx_screenmax_point(list (+ (car (getvar "viewctr")) (/ (*(/ (getvar "viewsize") (cadr (getvar "screensize"))) (car (getvar "screensize"))) 2))
         (+ (cadr (getvar "viewctr")) (/ (getvar "viewsize") 2))))
(setq width-x_lgx (- (car lgx_screenmax_point)(car lgx_screenmin_point)))
(setq height-y_lgx (- (cadr lgx_screenmax_point)(cadr lgx_screenmin_point)))
(setq half-y_lgx (+ (cadr lgx_screenmin_point)(* height-y_lgx 0.5)))
(if (and (/= tatoal nil)(> tatoal 0))
(progn
(setq grve_lgx nil)
(setq min-x_lgx (+ (car lgx_screenmin_point)(* width-x_lgx 0.25)))
(setq max-x_lgx (- (car lgx_screenmax_point)(* width-x_lgx 0.25)))
(if (and (/= tatoal1 nil)(> tatoal1 0))
(progn
(setq min-y_lgx (+ half-y_lgx (* height-y_lgx 0.005)))
(setq max-y_lgx (+ half-y_lgx (* height-y_lgx 0.025)))
)
(progn
(setq min-y_lgx (- half-y_lgx (* height-y_lgx 0.01)))
(setq max-y_lgx (+ half-y_lgx (* height-y_lgx 0.01)))
)
)
(setq grve_lgx (list (list min-x_lgx min-y_lgx)(list min-x_lgx max-y_lgx)
         (list min-x_lgx min-y_lgx)(list max-x_lgx min-y_lgx)
         (list min-x_lgx max-y_lgx)(list max-x_lgx max-y_lgx)
         (list max-x_lgx max-y_lgx)(list max-x_lgx min-y_lgx)))
(grvecs (cons 98 grve_lgx))
(setq grve_lgx nil)
(setq y_zl_lgx (/(* height-y_lgx 0.02) 11.0))
(if (/= current_pcs 0)
(setq x_zl_lgx (* width-x_lgx 0.5 (/ (float current_pcs) (float tatoal))))
(setq x_zl_lgx 0)
)
(setq max-x_lgx (+ min-x_lgx x_zl_lgx))
(repeat 10
(setq min-y_lgx (+ min-y_lgx y_zl_lgx))
(setq max-y_lgx min-y_lgx)
(setq grve_lgx (list (list min-x_lgx min-y_lgx)(list min-x_lgx max-y_lgx)
       (list min-x_lgx min-y_lgx)(list max-x_lgx min-y_lgx)
       (list min-x_lgx max-y_lgx)(list max-x_lgx max-y_lgx)
       (list max-x_lgx max-y_lgx)(list max-x_lgx min-y_lgx)))
(grvecs (cons 1 grve_lgx))
)
)
)
(if (and (/= tatoal1 nil)(> tatoal1 0))
(progn
(setq grve_lgx nil)
(setq min-x_lgx (+ (car lgx_screenmin_point)(* width-x_lgx 0.25)))
(setq max-x_lgx (- (car lgx_screenmax_point)(* width-x_lgx 0.25)))
(setq min-y_lgx (- half-y_lgx (* height-y_lgx 0.025)))
(setq max-y_lgx (- half-y_lgx (* height-y_lgx 0.005)))
(setq grve_lgx (list (list min-x_lgx min-y_lgx)(list min-x_lgx max-y_lgx)
         (list min-x_lgx min-y_lgx)(list max-x_lgx min-y_lgx)
         (list min-x_lgx max-y_lgx)(list max-x_lgx max-y_lgx)
         (list max-x_lgx max-y_lgx)(list max-x_lgx min-y_lgx)))
(grvecs (cons 98 grve_lgx))
(setq grve_lgx nil)
(setq y_zl_lgx (/(* height-y_lgx 0.02) 11.0))
(if (/= current1_pcs 0)
(setq x_zl_lgx (* width-x_lgx 0.5 (/ (float current1_pcs) (float tatoal1))))
(setq x_zl_lgx 0)  
)
(setq max-x_lgx (+ min-x_lgx x_zl_lgx))
(repeat 10
(setq min-y_lgx (+ min-y_lgx y_zl_lgx))
(setq max-y_lgx min-y_lgx)
(setq grve_lgx (list (list min-x_lgx min-y_lgx)(list min-x_lgx max-y_lgx)
       (list min-x_lgx min-y_lgx)(list max-x_lgx min-y_lgx)
       (list min-x_lgx max-y_lgx)(list max-x_lgx max-y_lgx)
       (list max-x_lgx max-y_lgx)(list max-x_lgx min-y_lgx)))
(grvecs (cons 1 grve_lgx))
)
)
)
)

(defun c:test()
(setq current 1)
(setq current1 1)
(while (/= (car (apply 'GRREAD '(t 7 0))) 11)
(progress_lgx current 1000 current1 100)
(setq current (+ current 1))
(setq current1 (+ current1 1))
(if (= current 1000) (setq current 1))
(if (= current1 100) (setq current1 1))
)
)

;;;How time can be used to control the progress bar is displayed, for example,
;;;I would like to use the following methods, but shows the process can not be displayed
;;;(progn
;;;(setq current 1)
;;;(repeat 51
;;;(setq time_start (getvar "cdate"))
;;;(while (< (* 1000000 (- (setq time_end (getvar "cdate")) time_start)) 0.03))
;;;(progress_lgx current 100 current 150)
;;;(setq current (+ current 2))
;;;)
;;;)
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

Sam

  • Bull Frog
  • Posts: 201
Re: Progress Bar
« Reply #38 on: July 06, 2016, 06:44:02 AM »
this is final version
by lgx
Code: [Select]
(defun progress_lgx(current_pcs tatoal current1_pcs tatoal1 / lgx_screenmin_point lgx_screenmax_point width-x_lgx
        height-y_lgx half-y_lgx grve_lgx min-x_lgx max-x_lgx y_zl_lgx x_zl_lgx)
;;;(progn  ;;;Examples are
;;;(setq current 0)
;;;(repeat 11
;;;(progress_lgx current 100 current 150)
;;;(while (/= (getpoint) nil))
;;;(setq current (+ current 10))
;;;)
;;;(repeat 11
;;;(progress_lgx current 100 current 0)
;;;(while (/= (getpoint) nil))
;;;(setq current (+ current 10))
;;;)
;;;)
;;;??,??:  ???
;;;?????
(redraw)
(setq lgx_screenmin_point(list (- (car (getvar "viewctr")) (/ (*(/ (getvar "viewsize") (cadr (getvar "screensize"))) (car (getvar "screensize"))) 2))
         (- (cadr (getvar "viewctr")) (/ (getvar "viewsize") 2))))
(setq lgx_screenmax_point(list (+ (car (getvar "viewctr")) (/ (*(/ (getvar "viewsize") (cadr (getvar "screensize"))) (car (getvar "screensize"))) 2))
         (+ (cadr (getvar "viewctr")) (/ (getvar "viewsize") 2))))
(setq width-x_lgx (- (car lgx_screenmax_point)(car lgx_screenmin_point)))
(setq height-y_lgx (- (cadr lgx_screenmax_point)(cadr lgx_screenmin_point)))
(setq half-y_lgx (+ (cadr lgx_screenmin_point)(* height-y_lgx 0.5)))
(if (and (/= tatoal nil)(> tatoal 0))
(progn
(setq grve_lgx nil)
(setq min-x_lgx (+ (car lgx_screenmin_point)(* width-x_lgx 0.25)))
(setq max-x_lgx (- (car lgx_screenmax_point)(* width-x_lgx 0.25)))
(if (and (/= tatoal1 nil)(> tatoal1 0))
(progn
(setq min-y_lgx (+ half-y_lgx (* height-y_lgx 0.005)))
(setq max-y_lgx (+ half-y_lgx (* height-y_lgx 0.025)))
)
(progn
(setq min-y_lgx (- half-y_lgx (* height-y_lgx 0.01)))
(setq max-y_lgx (+ half-y_lgx (* height-y_lgx 0.01)))
)
)
(setq grve_lgx (list (list min-x_lgx min-y_lgx)(list min-x_lgx max-y_lgx)
         (list min-x_lgx min-y_lgx)(list max-x_lgx min-y_lgx)
         (list min-x_lgx max-y_lgx)(list max-x_lgx max-y_lgx)
         (list max-x_lgx max-y_lgx)(list max-x_lgx min-y_lgx)))
(grvecs (cons 98 grve_lgx))
(setq grve_lgx nil)
(setq y_zl_lgx (/(* height-y_lgx 0.02) 11.0))
(if (/= current_pcs 0)
(setq x_zl_lgx (* width-x_lgx 0.5 (/ (float current_pcs) (float tatoal))))
(setq x_zl_lgx 0)
)
(setq max-x_lgx (+ min-x_lgx x_zl_lgx))
(repeat 10
(setq min-y_lgx (+ min-y_lgx y_zl_lgx))
(setq max-y_lgx min-y_lgx)
(setq grve_lgx (list (list min-x_lgx min-y_lgx)(list min-x_lgx max-y_lgx)
       (list min-x_lgx min-y_lgx)(list max-x_lgx min-y_lgx)
       (list min-x_lgx max-y_lgx)(list max-x_lgx max-y_lgx)
       (list max-x_lgx max-y_lgx)(list max-x_lgx min-y_lgx)))
(grvecs (cons 1 grve_lgx))
)
)
)
(if (and (/= tatoal1 nil)(> tatoal1 0))
(progn
(setq grve_lgx nil)
(setq min-x_lgx (+ (car lgx_screenmin_point)(* width-x_lgx 0.25)))
(setq max-x_lgx (- (car lgx_screenmax_point)(* width-x_lgx 0.25)))
(setq min-y_lgx (- half-y_lgx (* height-y_lgx 0.025)))
(setq max-y_lgx (- half-y_lgx (* height-y_lgx 0.005)))
(setq grve_lgx (list (list min-x_lgx min-y_lgx)(list min-x_lgx max-y_lgx)
         (list min-x_lgx min-y_lgx)(list max-x_lgx min-y_lgx)
         (list min-x_lgx max-y_lgx)(list max-x_lgx max-y_lgx)
         (list max-x_lgx max-y_lgx)(list max-x_lgx min-y_lgx)))
(grvecs (cons 98 grve_lgx))
(setq grve_lgx nil)
(setq y_zl_lgx (/(* height-y_lgx 0.02) 11.0))
(if (/= current1_pcs 0)
(setq x_zl_lgx (* width-x_lgx 0.5 (/ (float current1_pcs) (float tatoal1))))
(setq x_zl_lgx 0)  
)
(setq max-x_lgx (+ min-x_lgx x_zl_lgx))
(repeat 10
(setq min-y_lgx (+ min-y_lgx y_zl_lgx))
(setq max-y_lgx min-y_lgx)
(setq grve_lgx (list (list min-x_lgx min-y_lgx)(list min-x_lgx max-y_lgx)
       (list min-x_lgx min-y_lgx)(list max-x_lgx min-y_lgx)
       (list min-x_lgx max-y_lgx)(list max-x_lgx max-y_lgx)
       (list max-x_lgx max-y_lgx)(list max-x_lgx min-y_lgx)))
(grvecs (cons 1 grve_lgx))
)
)
)
)





(defun c:test2(/ current time_start loop time_end)
(setq current 1)
(repeat 101
(setq time_start (getvar "cdate"))
(setq loop t)
(while loop
(if (> (* 1000000 (- (setq time_end (getvar "cdate")) time_start)) 0.04)
(setq loop nil)
)
(princ)
(progress_lgx current 100 current 150)
)
(setq current (+ current 1))
)
)

(defun c:test1(/ current loop)
(setq current 1)
(setq loop t)
(while loop
(princ)
(progress_lgx current 150 current 100)
(setq current (+ current 0.05))
(if (>= current 100)
(setq loop nil)
)
)
)

(defun c:test(/ current loop)
(setq current 1)
(setq loop t)
(while loop
(princ)
(progress_lgx current 100 nil nil)
(setq current (+ current 0.05))
(if (>= current 100)
(setq loop nil)
)
)
)
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

Sam

  • Bull Frog
  • Posts: 201
Re: Progress Bar
« Reply #39 on: July 06, 2016, 06:58:37 AM »
one more
Code: [Select]
(DEFUN c:test (/ i)
  (GRTEXT -1 "Testing Process")
  (SETQ i -1)
  (REPEAT 10000 (progress (SETQ i (1+ i)) 10000 3))
  (GRTEXT)
)

(DEFUN progress        (i n bit / BOX INTEGER NUM REMAINDER)
  (SETQ        box (NTH bit
                 '(("")
                   ("" "▌")
                   ("" "▎" "▌" "▊")
                   ("" "▏" "▎" "▍" "▌" "▋" "▊" "▉")
                  )
            )
  )
  (SETQ num (EXPT 2 bit))
  (SETQ integer (FIX (/ (* 20 num i) n)))
  (SETQ remainder (REM integer num))
  (GRTEXT -2
          (STRCAT (SUBSTR "████████████████████"
                          1
                          (* 2 (FIX (/ integer num)))
                  )
                  (NTH remainder box)
          )
  )
)

;-----------------------------------

Function explanation:
1.progress function of bit parameters can be understood as the status line accuracy, and it is hoped the black block "█" subdivided into several Accept 0,1,2,3 four precision value.
2. Use the nth reason to see the following speed test, after all, it is not worth while displaying the progress bar to spend unnecessary time.
3. (GRTEXT -1 "Test Process") statement for an independent, not allowed to join the progress bar function, otherwise the status line frequently flashing, affect the display.
4. "████████████████████" alternative intermittent, such as "▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊ needed ▊▊▊▊ "

;----------------------------------------

(DEFUN Box1 (/ BOX I)
  (SETQ i -1)
  (REPEAT 8
    (SETQ i (1+ i))
    (SETQ box (NTH i '("" "▏" "▎" "▍" "▌" "▋" "▊" "▉")))
  )
)

(DEFUN Box2 (/ BOX I)
  (SETQ i -1)
  (REPEAT 8
    (SETQ i (1+ i))
    (COND ((= i 0) (SETQ box ""))
          ((= i 1) (SETQ box "▏"))
          ((= i 2) (SETQ box "▎"))
          ((= i 3) (SETQ box "▍"))
          ((= i 4) (SETQ box "▌"))
          ((= i 5) (SETQ box "▋"))
          ((= i 6) (SETQ box "▊"))
          ((= i 7) (SETQ box "▉"))
    )
  )
)
(DEFUN Box3 (/ BOX I)
  (SETQ i -1)
  (REPEAT 8
    (SETQ i (1+ i))
    (SETQ box (STRCAT (CHR 168) (CHR (- 136 i))))
  )
)
(DEFUN Box4 (/ BOX BOX0 BOX1 BOX2 BOX3 BOX4 BOX5 BOX6 BOX7 I)
  (SETQ Box0 "")
  (SETQ Box1 "▏")
  (SETQ Box2 "▎")
  (SETQ Box3 "▍")
  (SETQ Box4 "▌")
  (SETQ Box5 "▋")
  (SETQ Box6 "▊")
  (SETQ Box7 "▉")
  (setq i -1)
  (REPEAT 8
    (SETQ i (1+ i))
    (setq box (EVAL (READ (STRCAT "Box" (ITOA i)))))
  )
)
;;
;;Benchmarking .................Elapsed milliseconds / relative speed for 16384 iteration(s):
;;
;;    (BOX1).....1234 / 1.72 <fastest>
;;    (BOX2).....1469 / 1.45
;;    (BOX3).....1656 / 1.28
;;    (BOX4).....2125 / 1 <slowest>


Quote
Because of frequent calls grtext write status line affect the efficiency,
It improved again as follows, without prejudice to the progress bar shows the premise of reducing the number of calls grtext reserved posted first purpose is to facilitate the comparison of two ways.
The number of executions has been changed to 100,000, but most call 160 grtext, show the same effect

Code: [Select]
(DEFUN c:test (/ i)
  (GRTEXT -1 "Testing Process")
  (SETQ i -1)
  (REPEAT 100000 (progress (SETQ i (1+ i)) 100000 3))
  (GRTEXT)
)

(DEFUN progress        (i n bit / BOX INTEGER NUM REMAINDER)
  (SETQ num (EXPT 2 bit))
  (IF (OR (<= n (* num 20))
          (AND (> n (* num 20)) (= (REM i (FIX (/ n num 20))) 1))
      )
   (PROGN (SETQ box (NTH bit
                          '(("")
                            ("" "▌")
                            ("" "▎" "▌" "▊")
                            ("" "▏" "▎" "▍" "▌" "▋" "▊" "▉")
                           )
                     )
           )
           (SETQ integer (FIX (/ (* 20 num i) n)))
           (SETQ remainder (REM integer num))
           (GRTEXT -2
                   (STRCAT (SUBSTR "████████████████████"
                                   1
                                   (* 2 (FIX (/ integer num)))
                           )
                           (NTH remainder box)
                   )
           )
    )
  )
)
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html