Quantcast
Channel: Autodesk AutoCAD forums
Viewing all articles
Browse latest Browse all 14319

executeInApplicationContext. AutoCAD crashes when opened drawing loses focus.

$
0
0

Hey everyone,

 

I finally figured out how to get an ObjectARX program running! :)

 

Unfortunately, I am running into this crash that happens after loading my program.

In the InitAppMsg procedure, I call this function:

acDocManager->executeInApplicationContext(OpenDrawing, (void *)"c:\....pathtodwg");

OpenDrawing is defined as follows:

void OpenDrawing(void *fName) {
    int nChars = MultiByteToWideChar(CP_ACP, 0, (const char*) fName, -1, NULL, 0); //Get size of    buffer.
    const ACHAR *acName = new ACHAR[nChars]; //Create buffer to store converted string.
    MultiByteToWideChar(CP_ACP, 0, (const char*)fName, -1, (LPWSTR)acName, nChars); //Fill buffer.
    acDocManager->appContextOpenDocument(acName); //Use buffer
    delete [] acName; //Delete buffer from memory
}

 

 

The function call is successful and will open up the drawing.  However, when I click the default drawing that is opened when the AutoCAD instance is created, OR if I close the newly opened drawing, AutoCAD crashes.

 

What I am trying to do is open arbitrary AutoCAD drawings, possibly edit their database, then re-save them.

 

If you can help me out with this one, it'd be greatly appreciated.

Ask if me you have any questions or need more information. (.cpp entry point file is attached).

 

Thanks,

-Nicholas


Viewing all articles
Browse latest Browse all 14319

Trending Articles