ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

acutPrintf does not print to command line active prompt on the graphics screen

13 REPLIES 13
Reply
Message 1 of 14
sjbarnes
1020 Views, 13 Replies

acutPrintf does not print to command line active prompt on the graphics screen

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.

 

graphics screen during processgraphics screen during process

 

text screen during processtext screen during process

 

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...

 

graphics screen after processgraphics screen after process

 

text screen after processtext screen after process

 

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?

Labels (1)
13 REPLIES 13
Message 2 of 14

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
Expert Elite Member

Message 3 of 14

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. 

Message 4 of 14

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
Expert Elite Member

Message 5 of 14

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?

 

Message 6 of 14


@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
Expert Elite Member

Message 7 of 14
tbrammer
in reply to: sjbarnes

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.


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

Message 8 of 14

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
Expert Elite Member

Message 9 of 14

You are correct Alexander,

 

acedPrompt(L""); did not work. It probably last worked around the same time that my acutPrintf code worked.

 

Message 10 of 14
sjbarnes
in reply to: tbrammer

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.

Message 11 of 14

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
Expert Elite Member

Message 12 of 14

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.

Message 13 of 14

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
Expert Elite Member

Message 14 of 14

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost