Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using dos_lib "dos_getprogress function"?

Status
Not open for further replies.

vbcad

Technical User
Jul 12, 2002
159
US
I would like to use the get progress funtion in a lisp routine that is starting to become quite extensive. I can't figure out how to display the progress bar while the routine is running. I also can not find tutorials or any examples of its use online. The Autodesk website shows a use in VBA but not lisp. Any help is appreciated.
 
From dos_lib help:

dos_getprogress


--------------------------------------------------------------------------------


Displays a modeless dialog box that consists of a message, a progress bar, and an optional cancel button. Because the dialog box is modeless, you can use it when performing long processes that can be interrupted by the user. The function is called once with arguments to initialize the dialog box. Then, it is called any number of times to move the progress bar in an absolute or relative manner. It is called with no arguments to check the open status of the dialog box. It can be called with a T argument to close the dialog box.

Syntax
(dos_getprogress title message maxvalue [T])

(dos_getprogress abs/-rel)

(dos_getprogress T)

(dos_getprogress)

Parameters
title
A string containing the dialog box title.

message
A string containing a message.

maxvalue
An integer representing the maximum range value (between 0 and maxvalue) of the progress bar.

abs/-rel
An absolute position to move the progress meter, or a relative position (denoted with a negative sign) to move the progress meter.

T
If specified during the creation of the dialog box, an optional Cancel button is displayed. Otherwise, T closes the dialog box.



Returns
Returns nil when initializing, incrementing, and closing the dialog box.

When checking the open status, it return T if the dialog box is open, otherwise, nil is returned

Examples
Command: (setq x 0 y 1000)

1000

Command: (dos_getprogress "Testing" "Testing, please wait..." y)

nil

 
thanks i have looked at the help files. how do i get the progress bar to "read" what the lisp is doing. I undestand from the syntax of the counting loop it starts at zero and ends at 1000 using the setq statement. how does this function with a command already in progress? For example: the status bar that is displayed when a program is installing or running. I guess I just dont get it.
 
I'm making a guess based just on reading this...

I would say when you want a progreess bar/message displayed, first call it similar to the example;

(dos_getprogress "Testing" "Testing, please wait..." y)

Then you have to figure in your routine what "progress" level you are to change the progress bar, for a call like:

(dos_getprogress (* y 0.5))
for a 50% progress bar

Then when activity is done close progress d.b. with
(dos_getprogress T)
 
I believe i have this figured out. below is code for a sample routine that creates some layers. There must be an easier way to move the progress bar to streamline the coding. i know there probably is an easier way to code the layer creation also. I just wanted to get the progress bar to work. Any ideas on how to streamline the coding is welcome. dos_lib references are in red.
Code:
(DEFUN C:mla ()
        (SETQ SCMDE (GETVAR "CMDECHO"))                         ;RETRIEVES COMMAND ECHO STATUS
	(SETVAR "CMDECHO" 0)			;SETS COMMAND ECHO STATUS TO "0" (TURNS IT OFF)
	[COLOR=red](setq x 0 y 100)[/color]                       ;sets counting of progress bar
	[COLOR=red](dos_getprogress "Create Layers" "Creating Layers, please wait..." y)[/color] ;creates progress bar dialog
        (command "layer" "make" "1" "co" "170" "" "")
	(command "layer" "make" "2" "co" "170" "" "")
	(command "layer" "make" "3" "co" "170" "" "")
	(command "layer" "make" "4" "co" "170" "" "")
	(command "layer" "make" "5" "co" "170" "" "")
	(command "layer" "make" "6" "co" "170" "" "")
	(command "layer" "make" "7" "co" "170" "" "")
	(command "layer" "make" "8" "co" "170" "" "")
	(command "layer" "make" "9" "co" "170" "" "")
	(command "layer" "make" "10" "co" "170" "" "")
	[COLOR=red](dos_getprogress -10)  [/color]                        ;moves bar a relative value of 10 percent
	(command "layer" "make" "11" "co" "170" "" "")
	(command "layer" "make" "12" "co" "170" "" "")
	(command "layer" "make" "13" "co" "170" "" "")
	(command "layer" "make" "14" "co" "170" "" "")
	(command "layer" "make" "15" "co" "170" "" "")
	(command "layer" "make" "16" "co" "170" "" "")
	(command "layer" "make" "17" "co" "170" "" "")
	(command "layer" "make" "18" "co" "170" "" "")
	(command "layer" "make" "19" "co" "170" "" "")
	(command "layer" "make" "20" "co" "170" "" "")
[COLOR=red]	(dos_getprogress -10)[/color]
	(command "layer" "make" "21" "co" "170" "" "")
	(command "layer" "make" "22" "co" "170" "" "")
	(command "layer" "make" "23" "co" "170" "" "")
	(command "layer" "make" "24" "co" "170" "" "")
	(command "layer" "make" "25" "co" "170" "" "")
	(command "layer" "make" "26" "co" "170" "" "")
	(command "layer" "make" "27" "co" "170" "" "")
	(command "layer" "make" "28" "co" "170" "" "")
	(command "layer" "make" "29" "co" "170" "" "")
	(command "layer" "make" "30" "co" "170" "" "")
	[COLOR=red]	(dos_getprogress -10)[/color]
	(command "layer" "make" "31" "co" "170" "" "")
	(command "layer" "make" "32" "co" "170" "" "")
	(command "layer" "make" "33" "co" "170" "" "")
	(command "layer" "make" "34" "co" "170" "" "")
	(command "layer" "make" "35" "co" "170" "" "")
	(command "layer" "make" "36" "co" "170" "" "")
	(command "layer" "make" "37" "co" "170" "" "")
	(command "layer" "make" "38" "co" "170" "" "")
	(command "layer" "make" "39" "co" "170" "" "")
	(command "layer" "make" "40" "co" "170" "" "")
	[COLOR=red]	(dos_getprogress -10)[/color]
	(command "layer" "make" "41" "co" "170" "" "")
	(command "layer" "make" "42" "co" "170" "" "")
	(command "layer" "make" "43" "co" "170" "" "")
	(command "layer" "make" "44" "co" "170" "" "")
	(command "layer" "make" "45" "co" "170" "" "")
	(command "layer" "make" "46" "co" "170" "" "")
	(command "layer" "make" "47" "co" "170" "" "")
	(command "layer" "make" "48" "co" "170" "" "")
	(command "layer" "make" "49" "co" "170" "" "")
	(command "layer" "make" "50" "co" "170" "" "")
	[COLOR=red]	(dos_getprogress -10)[/color]
	(command "layer" "make" "51" "co" "170" "" "")
	(command "layer" "make" "52" "co" "170" "" "")
	(command "layer" "make" "53" "co" "170" "" "")
	(command "layer" "make" "54" "co" "170" "" "")
	(command "layer" "make" "55" "co" "170" "" "")
	(command "layer" "make" "56" "co" "170" "" "")
	(command "layer" "make" "57" "co" "170" "" "")
	(command "layer" "make" "58" "co" "170" "" "")
	(command "layer" "make" "59" "co" "170" "" "")
	(command "layer" "make" "60" "co" "170" "" "")
	[COLOR=red]	(dos_getprogress -10)[/color]
	(command "layer" "make" "61" "co" "170" "" "")
	(command "layer" "make" "62" "co" "170" "" "")
	(command "layer" "make" "63" "co" "170" "" "")
	(command "layer" "make" "64" "co" "170" "" "")
	(command "layer" "make" "65" "co" "170" "" "")
	(command "layer" "make" "66" "co" "170" "" "")
	(command "layer" "make" "67" "co" "170" "" "")
	(command "layer" "make" "68" "co" "170" "" "")
	(command "layer" "make" "69" "co" "170" "" "")
	(command "layer" "make" "70" "co" "170" "" "")
	[COLOR=red]	(dos_getprogress -10)[/color]
	(command "layer" "make" "71" "co" "170" "" "")
	(command "layer" "make" "72" "co" "170" "" "")
	(command "layer" "make" "73" "co" "170" "" "")
	(command "layer" "make" "74" "co" "170" "" "")
	(command "layer" "make" "75" "co" "170" "" "")
	(command "layer" "make" "76" "co" "170" "" "")
	(command "layer" "make" "77" "co" "170" "" "")
	(command "layer" "make" "78" "co" "170" "" "")
	(command "layer" "make" "79" "co" "170" "" "")
	(command "layer" "make" "80" "co" "170" "" "")
	[COLOR=red]	(dos_getprogress -10)[/color]
	(command "layer" "make" "81" "co" "170" "" "")
	(command "layer" "make" "82" "co" "170" "" "")
	(command "layer" "make" "83" "co" "170" "" "")
	(command "layer" "make" "84" "co" "170" "" "")
	(command "layer" "make" "85" "co" "170" "" "")
	(command "layer" "make" "86" "co" "170" "" "")
	(command "layer" "make" "87" "co" "170" "" "")
	(command "layer" "make" "88" "co" "170" "" "")
	(command "layer" "make" "89" "co" "170" "" "")
	(command "layer" "make" "90" "co" "170" "" "")
	[COLOR=red]	(dos_getprogress -10)[/color]
	(command "layer" "make" "91" "co" "170" "" "")
	(command "layer" "make" "92" "co" "170" "" "")
	(command "layer" "make" "93" "co" "170" "" "")
	(command "layer" "make" "94" "co" "170" "" "")
	(command "layer" "make" "95" "co" "170" "" "")
	(command "layer" "make" "96" "co" "170" "" "")
	(command "layer" "make" "97" "co" "170" "" "")
	(command "layer" "make" "98" "co" "170" "" "")
	(command "layer" "make" "99" "co" "170" "" "")
	(command "layer" "make" "100" "co" "170" "" "")
	[COLOR=red]	(dos_getprogress -10)[/color]
[COLOR=red]	(dos_getprogress t)[/color]                            ;closes progress bar dialog
        
        
        (COMMAND "REDRAW")					;REFRESH SCREEN DISPLAY
	(SETVAR "CMDECHO" SCMDE)				;RESTORES COMMAND ECHO TO ORIGINAL VALUE
        (PRINC)                                                 ;PRINTS nil WHEN FINISHED (QUIET EXIT)
)
 
One way to streamline the code would be to make a list of layers:

(setq laylist '("1" "2" etc..."100"))

Then create the layers with;

(foreach x laylist
(command "layer" "make" x "co" "170" "" "")
)

You could make a counter in the list that increments, when it hits 10 reset and do the 'getprogress', maybe

(if (= 10 Count)
(progn
(setq Count 1)
(dos_getprogress -10)
)
(setq Count 1)

)
 
here is what i have. I do not understand how to set up the counter in the routine. I did a setq for the layer names. this doesnt work as I want as it will go up to an infinite percentage on the dialog display. this looks bad on the routine. I added as absolute 100% at the end,however this would also not be desirable on a slower routine that the progress bar would go much slower. Layer numbers are at random and do not mean anything. Any ideas?

Code:
  (DEFUN C:mla ()
        (SETQ SCMDE (GETVAR "CMDECHO"))                         ;RETRIEVES COMMAND ECHO STATUS
	(SETVAR "CMDECHO" 0)			;SETS COMMAND ECHO STATUS TO "0" (TURNS IT OFF)
	(setq x 0 y 100)                        ;sets counting of progress bar
	(dos_getprogress "Create Layers" "Creating Layers, please wait..." y) ;creates progress bar dialog
	
        
(setq LayList '(
			"1"
			"2"
			"3"
			"4"
			"5"
			"6"
			"7"
			"8"
			"9"
			"10"
			"11"
			"12"
			"13"
			"14"
			"15"
			"16"
			"17"
			"18"
			"19"
			"20"
			"21"
			"22"
			"23"
			"24"
			"25"
			"26"
			"27"
			"28"
			"29"
			"30"
			"31"
			"32"
			"33"
			"34"
			"35"
			"36"
			"37"
			"38"
			"39"
			"40"
			"41"
			"42"
			"43"
			"44"
			"45"
			"46"
			"47"
			"48"
			"49"
			"50"
			"52"
			"53"
			"54"
			"55"
			"56"
			"57"
			"58"
			"59"
			"24"
			"58"
			"59"
			"24"
			"25"
			"26"
			"27"
			"28"
			"29"
			"30"
			"31"
			"32"
			"33"
			"34"
			"35"
			"36"
			"37"
			"38"
			"39"
			"40"
			"41"
			"42"
			"43"
			"44"
			"45"
			"46"
			"47"
			"48"
			"49"
			"50"
			"52"
			"53"
			"54"
			"55"
			"25"
			"26"
			"27"
			"28"
			"29"
			"30"
			"31"
			"32"
			"33"
			"34"
			"35"
			"36"
			"37"
			"38"
			"39"
			"40"
			"41"
			"42"
			"43"
			"44"
			"45"
			"46"
			"47"
			"48"
			"49"
			"50"
			"52"
			"53"
			"54"
			"55"
			"56"
			"57"
			"58"
			"59"
			"60"
			"60"))

(foreach x laylist
    (command "layer" "make" x "co" "170" "" "")
)

(foreach x LayList
		(setq LayName (strcat x))
		(dos_getprogress -1)
		)
 		(DOS_GETPROGRESS 100)			       ;SETS PERCENTAGE TO 100%
		(dos_getprogress t)                            ;closes progress bar dialog
        
        
        (COMMAND "REDRAW")					;REFRESH SCREEN DISPLAY
	(SETVAR "CMDECHO" SCMDE)				;RESTORES COMMAND ECHO TO ORIGINAL VALUE
        (PRINC)                                                 ;PRINTS nil WHEN FINISHED (QUIET EXIT)
)
 
I was thinking the "getprogress" calls/updates would be made in the "foreach" loop as that is where the layers are created that will take some time - but not much I wouldn't think.

----------------------------------------

(foreach x laylist
(command "layer" "make" x "co" "170" "" "")
(dos_getprogress -1)
)
(DOS_GETPROGRESS 100) ;SETS PERCENTAGE TO 100%
(dos_getprogress t) ;closes progress bar dialog
 
that also works. This is what i am trying to prevent; if i count each layer created the dialog shows 128% in the percent complete dialog.(I am making 128 layers or it coulbe 1000 layers etc.) Any way around this? Is it possible to have the routine "know" how many layers are to be created and then adjust the percentage accordingly. Numbers in decimal form do not work in the progress command.
 
To get progress bar to better track percent complete you need to add a few steps.

1. get total # of layers to be created, say from (setq NumLay (length layList))
2. Decide how often to update progress, say every 5%:(setq Step (fix (* NumLay 0.05)))
3. Use a counter in the 'repeat' that increments by 1, and when Count=Step reset Count to 1 and issue a 'getprogress':

(if (= Step Count)
(progn
(setq Count 1)
(dos_getprogress (- Step))
)
(setq Count (+ 1 Count))
)
 
Oops, correction on part of code;
getprogress should not be incremented by 'Step' which is a number that varies depending on length of list, but by your selected update increment. In the example that is 5%, so it would be (dos_getprogress -5)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top