cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
NH
Contributor

Crash upon opening a file (File > Open) after executing DWG export via Add-On API (AC27 – AC30)

Hi everyone,

I would like to ask for advice or assistance regarding a crash issue when exporting DWG files via an add-on.

Overview: This issue was first observed in Archicad 27 Japanese edition and still persists up to Archicad 30 Japanese edition. When we reported this issue previously through direct support, we were informed that it was recognized as a bug and scheduled to be fixed based on priority. However, as it remains unfixed, many features in our add-on execute up to Step 4 below, which causes Archicad to crash deterministically in certain workflows. This is causing significant issues for our users.

Steps to Reproduce

(Note: These steps were recorded on AC27, but the behavior appears to remain the same in recent versions.)

  1. Launch Archicad 27 with a new/empty project. Switch the view to 3D Perspective, create a single box Morph, and save the project as a .pln file while remaining in the 3D Perspective view. Close Archicad.

  2. In the API Development Kit Example projects, open Communication_Manager and replace the target function with the source code provided below, then build the add-on.

  3. Launch Archicad 27 and open the .pln file saved in Step 1.

  4. Execute the menu command Test > Communication_Manager > Save External Files as DWG (created in Step 2). Confirm that a 3D DWG file is generated successfully in your Documents folder.

  5. Go to File > Open and load the .pln file from Step 1 (or any other .pln file).

  6. Once the file opens in 3D Perspective view, move the mouse cursor into the main view area. Archicad crashes immediately.

static void Do_CallExternalSaveAsDWG(void)
{
    API_ModulID        mdid = { 1198731108, 1322668197 };        // DXF/DWG add-on
    API_MDCLParameter  par;
    GSHandle           parHdl;
    GSErrCode          err;
    IO::Location       configFile;

    // Change 3D View
    API_WindowInfo     windInfo;
    BNZeroMemory(&windInfo, sizeof(windInfo));
    windInfo.typeID = APIWind_3DModelID;
    err = ACAPI_Window_ChangeWindow(reinterpret_cast<const API_WindowInfo*> (&windInfo));

    // Local call DWG add-on to retrieve the default translator
    err = ACAPI_AddOnAddOnCommunication_InitMDCLParameterList(&parHdl);
    if (err != NoError)
        return;

    par = {};
    par.name = "Mode";
    par.type = MDCLPar_string;
    par.string_par = "Default";
    err = ACAPI_AddOnAddOnCommunication_AddMDCLParameter(parHdl, &par);
    IO::Location loc;
    if (err == NoError) {
        err = ACAPI_AddOnAddOnCommunication_Call(&mdid, 'GDCO', 1, parHdl, (GSPtr)&loc, false);    // Get default translator
    }

    if (err == NoError)
        configFile.Set(loc.ToDisplayText());

    ACAPI_AddOnAddOnCommunication_FreeMDCLParameterList(&parHdl);

    if (!configFile.IsLegalInNativeFileSystem())
        return;

    IO::Location outputLoc;
    API_SpecFolderID specID = API_UserDocumentsFolderID;
    ACAPI_ProjectSettings_GetSpecFolder(&specID, &(outputLoc));
    outputLoc.AppendToLocal(IO::Name("TestOut.DWG"));

    err = ACAPI_AddOnAddOnCommunication_InitMDCLParameterList(&parHdl);
    if (err != NoError) return;

    char    str[512];
    IO::URL url;
    BNZeroMemory(&par, sizeof(par));
    par.name = "FileName";
    par.type = MDCLPar_string;
    outputLoc.ToURL(&url);
    CHTruncate((const char*)url, str, sizeof(str));
    par.string_par = str;
    err = ACAPI_AddOnAddOnCommunication_AddMDCLParameter(parHdl, &par);

    if (err != NoError) return;
    BNZeroMemory(&par, sizeof(par));
    par.name = "ConfigFile";
    par.type = MDCLPar_string;
    configFile.ToURL(&url);
    CHTruncate((const char*)url, str, sizeof(str));
    par.string_par = str;
    err = ACAPI_AddOnAddOnCommunication_AddMDCLParameter(parHdl, &par);

    if (err != NoError) return;

    err = ACAPI_AddOnAddOnCommunication_Call(&mdid, 'SAV3', 1, parHdl, NULL, true);

    if (err != NoError) return;

    ACAPI_AddOnAddOnCommunication_FreeMDCLParameterList(&parHdl);

    return;
}

Has anyone encountered a similar behavior or found a workaround/bypass for this issue? Any insights or suggestions would be greatly appreciated.

Thank you in advance!

 

Operating system used: Windows 11 25H2

0 Replies 0

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!

Video Thumbnail