I have a legacy ARX that provides feedback during a potentially time consuming process. The intention is for the feedback to appear in the command line active prompt on the graphics screen. The process involves moving texts so they don't clash.
The feedback provides rolling numerical information on progress to the user.
This is the code...
acutPrintf(_T("\r Trying to unclash text %i out of %i texts. Failed to unclash %i texts. Task %5.2f%% completed."), inttxt, maxtxt, notdone, per);
However, acutPrintf does not produce any output on the graphics screen, but does produce output on the text screen.
this output is constantly updated one text at a time during the process.
acutPrintf output is eventually produced above the command line, but only when the process has completed...
So, if the user does not have the text screen visible, they receive no feedback until the process is compete.
acedAlert behaves in an identical manner.
Many years ago (probably around AutoCAD 2010) this feedback used to work as intended.
Can I do anything to get this feedback to produce output on the graphics screen?
As far as I remember "\r" is not working in AutoCAD command line. You can use string with many "\b" instead. So result will be such this:
If you interesting with this source code - I can provide full project.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
Thank you Alexander.
Yes, please let me have your project. I would like to see how you achieve your output.
Simply replacing "\r" with "\b" in my project altered the text screen output, but did nothing on the graphics screen.
OK. I've attached project. Command Progress2 is in ProgressBarsEng.lsp
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
Thank you again Alexander.
I could not open your project as I still use VS2017 for AutoCAD 2020, but I did read through the .lps & .cpp files included with the project, so I can see what is being done. Apologies for not making this clear before now.
Is there no way to get acutPrintf to print to the command line active prompt on the graphics screen during a command, other than creating a replacement method to write to the command line active prompt?
@sjbarnes wrote:
Is there no way to get acutPrintf to print to the command line active prompt on the graphics screen during a command, other than creating a replacement method to write to the command line active prompt?
I do not know other way. You can try to call acedPrompt(L""); after acedPrintf(...) in order to refresh command line. But as I remember this method work only in very old versions of AutoCAD.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
How about using the progressmeter API functions of ObjectARX?
/* 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();
Or if you intend to update the graphic screen you could try this:
actrTransactionManager->queueForGraphicsFlush();
actrTransactionManager->flushGraphics();
acedUpdateDisplay();
Make sure that you are not within a transaction when you call this.
There is an undocumented function (since AutoCAD 2015):
void __cdecl adsi_flushcommandline(void);
This function flush commandline, so if you call this function after calling acutPrintf(_T("\r..."), ...) - line will be refreshed in commandline. Try it.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
You are correct Alexander,
acedPrompt(L""); did not work. It probably last worked around the same time that my acutPrintf code worked.
Thanks Thomas,
actrTransactionManager->queueForGraphicsFlush();
actrTransactionManager->flushGraphics();
acedUpdateDisplay();
did not work for me.
progressmeter is my fall back plan if I cannot get my customized numerical feedback to work.
Try this sample code:
//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
//-----------------------------------------------------------------------------
#define szRDS _RXST("")
void __cdecl adsi_flushcommandline(void);
int OnIdleAcadInternal(void) {
CWinApp* app = acedGetAcadWinApp();
CWnd* wnd = app->GetMainWnd();
MSG msg;
while (::PeekMessage(&msg, wnd->m_hWnd, 0, 0, PM_NOREMOVE)) {
if (!app->PumpMessage()) {
::PostQuitMessage(0);
break;
}
}
LONG lIdle = 0;
//while (app->OnIdle(lIdle++)&& lIdle < 1000);
return RSRSLT;
}
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CTestCommandLineApp : public AcRxArxApp {
public:
CTestCommandLineApp() : AcRxArxApp() {}
virtual AcRx::AppRetCode On_kInitAppMsg(void* pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg(pkt);
return (retCode);
}
virtual AcRx::AppRetCode On_kUnloadAppMsg(void* pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kUnloadAppMsg(pkt);
return (retCode);
}
virtual void RegisterServerComponents() { }
static void RivilisTestCommandLine() {
for (int i = 0; i <= 100; i++)
{
acutPrintf(_T("\rPercents: %d%%"), i);
OnIdleAcadInternal();
adsi_flushcommandline();
Sleep(100);
}
}
};
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CTestCommandLineApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CTestCommandLineApp, Rivilis, TestCommandLine, TestCommandLine, ACRX_CMD_MODAL, NULL)
Video: https://autode.sk/3m8ZrCs
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
Thanks again Alexander,
I tried to integrate your sample code into my project, but without OnIdleAcadInternal() it did nothing other than slow down the process (probably down to sleep(100)). I could not successfully include OnIdleAcadInternal() as my project does not include MFC & making the changes so that CWinApp* could be found created too many other problems.
Sorry, but without using MFC there is no method to dispatch message loop in order AutoCAD can update it's UI.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
Alexander, thanks again for your continued good advice.
In that case, I think I need to abandon my original plans to replicate the old command line output & replace with progressmeter then implement different command line feedback when process is complete.