How to include progress meter

How to include progress meter

Anonymous
Not applicable
1,963 Views
7 Replies
Message 1 of 8

How to include progress meter

Anonymous
Not applicable

Hi all,

 

I want to include progress meter in my processing to let the user wait until the process stops .How can I include it ?

 

thanks

Pradeep

0 Likes
Accepted solutions (2)
1,964 Views
7 Replies
Replies (7)
Message 2 of 8

tbrammer
Advisor
Advisor
Accepted solution

You could use the Progress Bar API. See core_rxmfcapi.h:

 

// Progress Bar API

/* acedSetStatusBarProgressMeter
 * Creates a progress meter on AutoCAD status bar.
 * Returns 0 if it successfully creates the label and progress meter. 
 * Otherwise -1
 */
int acedSetStatusBarProgressMeter(const ACHAR* pszLabel, int nMinPos, 
                                  int nMaxPos);
/* acedSetStatusBarProgressMeter
 * Call this with a positive value within the range specified to set 
 * the current position of the status bar.  
 * Pass a negative number to add an amount to the current position (relative).
 */
int acedSetStatusBarProgressMeterPos(int nPos);

/* acedRestoreStatusBar
 * Resets AutoCAD status bar
 */
void acedRestoreStatusBar();

Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 8

Anonymous
Not applicable

thank you so much ..still wondering how to close this meter on process done .How to sync the things ?

0 Likes
Message 4 of 8

tbrammer
Advisor
Advisor
Accepted solution

@Anonymous wrote:

(...) how to close this meter on process done .How to sync the things ?


To initialize: acedSetStatusBarProgressMeter(L"My progresss text", int nMinPos, int nMaxPos)

You have to figure out yourself how nMinPos and nMaxPos are about to work for you.

 

To "sync": acedSetStatusBarProgressMeterPos(pos);

To "close": acedRestoreStatusBar();

 

Example:

 

int count = 123;
int progErr;
progErr = acedSetStatusBarProgressMeter(L"My Progress:", 0, count-1);

for (int i=0; i<count; ++i)
{
	DoMyStep(i); // <-- your code
	if (!progErr)
	    acedSetStatusBarProgressMeterPos(i);
}
if (!progErr)
	acedRestoreStatusBar();

Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 5 of 8

Anonymous
Not applicable

I am wondering how to implement this . I mean do I need to keep this in a separate thread or I need to create a callback function which will show its progress each time an item ie part of item is being imported . What is the best approach ?

0 Likes
Message 6 of 8

tbrammer
Advisor
Advisor

@Anonymous wrote:

I am wondering how to implement this . I mean do I need to keep this in a separate thread or I need to create a callback function which will show its progress each time an item ie part of item is being imported . What is the best approach ?


I gave a simple example in my last post. This could be within a long-running registered command-function.

Just call acedSetStatusBarProgressMeterPos(pos) whenever another piece of work is done. No callbacks or separate threads needed.

 

I'm not sure whether the progress bar API would work when called from another thread because ObjectARX is single-threaded.

Is the process for which you want to display the progress running in a registered command?

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 7 of 8

Anonymous
Not applicable

Hi! 

Where is code of 

acedSetStatusBarProgressMeter?

 

0 Likes
Message 8 of 8

Alexander.Rivilis
Mentor
Mentor

Definition: core_rxmfcapi.h

Linking: accore.lib (for AutoCAD 2013+) or acad.lib (for AutoCAD 2012-)

 
 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member