Displaying program progress on screen not a progressbar

Displaying program progress on screen not a progressbar

Anonymous
Not applicable
1,866 Views
12 Replies
Message 1 of 13

Displaying program progress on screen not a progressbar

Anonymous
Not applicable

Hi,

 

I am writing a small game for AutoCAD in vb.net and would like to see the progress after each loop in the program. I tried committing the transaction with  regen for each loop and showing and hiding the main form but it only shows the final product. If I put a getstring in the loop it shows the progress up to that point but I don't want the user to have to keep hitting enter to see the progress. I wrote it in autolisp as well and that shows the progress with each step but its way too slow. Any suggestions would be welcome.

 

Thanks in advance.

0 Likes
1,867 Views
12 Replies
Replies (12)
Message 2 of 13

dlanorh
Advisor
Advisor
Is this a .NET question (program progress) or a Lisp question (speed it up)? If it's the former, it's in the wrong Forum; if the latter, we can't help without seeing the code.

I am not one of the robots you're looking for

0 Likes
Message 3 of 13

pbejse
Mentor
Mentor

@Anonymous wrote:

I wrote it in autolisp as well and that shows the progress with each step but its way too slow. Any suggestions would be welcome.


What approach did you use to show an on-screen  progress bar with lisp?  Do you mind posting your code so we could effectively give you better suggestions.

 

 

 

0 Likes
Message 4 of 13

_Tharwat
Advisor
Advisor

Good morning. 🙂

I guess the OP indicates to acets functions. eg: acet-ui-progress-init,safe,done. 

0 Likes
Message 5 of 13

pbejse
Mentor
Mentor

@_Tharwat wrote:

Good morning. 🙂

I guess the OP indicates to acets functions. eg: acet-ui-progress-init,safe,done. 


 

 

You are probably right, I keep forgetting there are tons of  acet functions out there. 

Anyway, back then,  i've taken the fill_image route with DCL to create a progress bar. Thats why i'm interested what the OP's approach was, could be something new.

 

 

 

0 Likes
Message 6 of 13

john.uhden
Mentor
Mentor

I was thinking about using a 2D solid and stretching it out horizontally over time...

(defun @progressbar (p10 height width / p11 p12 p13 w t1 t2 ent)
  (graphscr)
  (setq p12 (mapcar '+ p10 (list 0 height 0)))
  (setq w (* width 0.1))
  (setq p11 (mapcar '+ p10 (list w 0 0))
        p13 (mapcar '+ p12 (list w 0 0))
  )
  (vl-cmdf "_.solid" "_non" p10 "_non" p11 "_non" p12 "_non" p13 "")
  (setq ent (entget (entlast)))
  (setq t1 (getvar "date"))
  (setq t2 t1)
  (while (< w width)
    (while (< (- (setq t2 (getvar "date")) t1) 1e-6))
    (setq w (+ w 1))
    (setq p11 (mapcar '+ p10 (list w 0 0))
          p13 (mapcar '+ p12 (list w 0 0))
    )
    (setq ent (subst (cons 11 p11)(assoc 11 ent) ent))
    (setq ent (subst (cons 13 p13)(assoc 13 ent) ent))
    (entmod ent)
    (setq t1 t2)
  )
)

Well that didn't work too well.  A white screen just kept blinking at me until it ended, but at least the solid had grown.

John F. Uhden

0 Likes
Message 7 of 13

john.uhden
Mentor
Mentor

DOSLIB has a progressbar function.

John F. Uhden

0 Likes
Message 8 of 13

dlanorh
Advisor
Advisor

How about finding a use for the long forgotten Trace instead of a solid. You can still draw them using the ".trace" command.

I am not one of the robots you're looking for

0 Likes
Message 9 of 13

john.uhden
Mentor
Mentor
I dunno. Does the TRACE entity avoid the blinking screen issue?
Do traces have a width property? An LWPOLYLINE does.

John F. Uhden

0 Likes
Message 10 of 13

Sea-Haven
Mentor
Mentor

Maybe  a (princ asq) the asq is the extended character of a filled sq.  will go across command line. 

 

 

(Repeat 25
(princ (chr 149))
(command "delay" 200)
(princ)
)

 

 

0 Likes
Message 11 of 13

john.uhden
Mentor
Mentor
I think I have it figured, just nothing written yet... grdraw.
I'l try to get a rudimentary one working for testing purposes. Then will
have to adjust for pixel size and viewtwist. My LABEL_IT program uses
grdraw to create glyphs that emulate AutoCAD's object snaps. They are
amazingly fast..

John F. Uhden

0 Likes
Message 12 of 13

john.uhden
Mentor
Mentor

Okay, here ya go.  A progressbar function in plain AutoLisp

(defun @progressbar (ang color % / i 1/2pi pixel nh ss vc vw LL UR p p1 p2 p3 p4)
  ;; ang is the horizontal angle of the bar in preparation for handling twisted views (future)
  ;;   It currently works only for an angle of zero in a non-twisted view
  ;; color is any of the normal AutoCAD color integers from 1 though 255
  ;; % is an integer representing the percent progress
  ;; Note that all these computations are repeated with each change in % because the user
  ;;   may have zoomed in or out randomly any number of times, so the values can keep changing.
  ;; The position of the bar in this initial release is always at the lower left corner of the screen.
  ;; It is intended that future releases will provide options for TL, TC, TR, BL, BC, BR
  ;; The dimensions were selected to please the author;
  ;;    feel free to change them to please yourself.
  (setq i 0.0
        1/2pi (* 0.5 pi)
        ss (getvar "screensize") ;; in pixels
        vc (getvar "viewctr") ;; in dwg units
        vs (getvar "viewsize") ;; view height in dwg units
        vw (* vs (apply '/ ss)) ;; view width in dwg units
        wid (* 0.25 vw) ;; bar width in dwg units
        ht (* 0.15 wid) ;; bar height in dwg units
        pixel (/ vs (cadr ss)) ; pixel height in dwg units
        nh (fix (/ ht pixel))
        LL (mapcar '- vc (mapcar '* '(0.5 0.5)(list vw vs)))
        UR (mapcar '+ vc (mapcar '* '(0.5 0.5)(list vw vs)))
        p (polar LL (angle LL UR)(* 0.05 (distance LL UR)))
        p1 p
        p2 (polar p1 1/2pi ht)
        p3 (polar p1 ang wid)
        p4 (polar p2 ang wid)
  )
  (repeat (max 4 (fix (* nh 0.1)))
    (grdraw p1 p2 254) ;; border point
    (grdraw p2 p4 254) ;; border point
    (grdraw p1 p3 254) ;; border point
    (grdraw p3 p4 254) ;; border point
    (setq p1 (polar p1 (+ ang (* 1.25 pi))(* 1.414 pixel))
               p2 (polar p2 (+ ang (*  0.75 pi))(* 1.414 pixel))
               p3 (polar p3 (+ ang (*  1.75 pi))(* 1.414 pixel))
               p4 (polar p4 (+ ang (*  0.25 pi))(* 1.414 pixel))
    )
  )
  (setq p1 p)
  (repeat nh
    (setq p2 (polar p1 ang (* 0.01 wid %)))
    (grdraw p1 p2 color)
    (setq p1 (polar p1 1/2pi pixel))
  )
)
(defun @progresstest ( / %)
  (setq % 0.0)
  ;; The following while loop is just for testing.
  ;; In real use, you must keep track of the % of progress, and
  ;; call the @progressbar function each time it changes.
  ;; In this test, just move your cursor around to see the progress,
  ;;    or type anything on the keyboard, or both.
  (while (and (grread 1)(<= % 100))
    (@progressbar 0.0 4 (setq % (1+ %)))
  )
  (princ "\nDone.")
)

John F. Uhden

0 Likes
Message 13 of 13

Sea-Haven
Mentor
Mentor

Another method 

 

(setq str "")
(setvar 'cmdecho 0)
(repeat 100
(setq str (strcat str "0"))
(setvar "modemacro" str)
(command "delay" 100)
)
(setvar "modemacro" "")
0 Likes