<?xml encoding=”UTF-8″>By Philippe Leefsma
Q:
I need to detect when AutoCAD is running in background plot in order to handle this appropriately concerning my custom applications.
What is the best way to achieve this?
A:
One suggestion is to check using Win32 API “GetCommandLine” the command line string used to run AutoCAD and parse it to see if it contains the “-b” and “-pl” switches.
Here is my demand loaded arx startup procedure:
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt)
{
// TODO: Load dependencies here
// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
// TODO: Add your initialization code here
ACHAR* cmdline = GetCommandLine();
std::ofstream ofs(
L“c:\Temp\log.txt”,
std::ios::out | std::ios::binary);
std::wstring wstr(cmdline);
ofs.write((char *) wstr.c_str(), wstr.length() * sizeof(wchar_t));
ofs.close();
return (retCode) ;
}
<
p class=”MsoNormal”>–
Once a background plot has been run, the content of my log file is as follow:
<font size="3"><em>"C:Program FilesAutodeskACADM 2009acad.exe" </em></font>
<font size="3"><em>-pl -b C:DOCUME~1leefsmpLOCALS~1TempBG074D~1BGPlot.scr</em></font>

Leave a Reply