Friday, December 15, 2006

Hello,

I'm sure you probably have faced a situation where you perform some heavy calculations inside AutoCAD with or without a dialog running. In these cases AutoCAD may look frozen and this may look strange to the user because it may think AutoCAD has really frozen and then the user may try to close it.

Even if you use a progress bar like AutoCAD status bar if you change the current window and get back to AutoCAD it may look frozen in black/white colors.

This occurs because the processor focus all its resources into your heavy loop and does not save enough time to both AutoCAD and your dialog process its own messages. These messages will affect several things like, for instance, the dialog graphics update.

The below function will let AutoCAD do this and you may call it from inside your loop (maybe a FOR or WHILE heavy statements). This way, on each interaction, this function will let AutoCAD process its messages.

void PumpAcadMessages()
{
// Get AutoCAD application
CWinApp* app = acedGetAcadWinApp();
// Get Main window
CWnd* wnd = app->GetMainWnd();
// dispatch incoming sent messages

MSG msg;
while (::PeekMessage (&msg, wnd->m_hWnd, 0, 0, PM_NOREMOVE))
{
// if can't pump, break
if (!app->PumpMessage())
{
::PostQuitMessage(0);
break;
}
}
LONG lIdle = 0;
// Now it's time to MFC do the work
while (app->OnIdle(lIdle++));
}

If you also would like to process your dialog messages you just need to change the first two lines and use your dialog's CWnd pointer instead of AutoCAD window's pointer.

Cheers!

Thursday, December 14, 2006

AU2006 was fantastic!

Hello,

Au2006 was amazing. There were almost 7500 people this year and several classes were provided.
If you would like to check those classes visit AU Online at: http://www.autodesk.com/auonline

I will post some content of my class but I need first to reorganize its topics and pictures.
Stay tuned.

Cheers!