Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

How to call ACAPI_Automate(APIDo_SaveID) inside ACAPI_CallUndoableCommand scope?

Anonymous
Not applicable
Hello guys,

I call a function in ACAPI_CallUndoableCommand scope and inside this function I call ACAPI_Automate(APIDo_SaveID) and ACAPI_Automate is not working:

ACAPI_CallUndoableCommand("Import Files", [&]() -> GSErrCode { ImportFiles(); return (0); });

void ImportFiles()
{
        ...
        ACAPI_Automate(APIDo_SaveID);
}
Is there a way to get out of this scope or I have to call it outside ImportFiles?
1 ACCEPTED SOLUTION

Solution
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi,

APIDo_SaveID is not allowed to be called inside ACAPI_CallUndoableCommand scope.
Sorry, you have to call it outside.

Regards,
Tibor

View solution in original post

4 REPLIES 4

Solution
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi,

APIDo_SaveID is not allowed to be called inside ACAPI_CallUndoableCommand scope.
Sorry, you have to call it outside.

Regards,
Tibor

Tibor,

If I understand this correctly, this prevents me from creating a custom menu [AC23] with a choice that updates all drawings and saves.  I understand I have to reserve before I can save a Teamwork file.  However, I am the only one working in a non-Teamwork .pln file.  I am using Do_Save_Plan() found in the AC23 Examples Automate_Functions.cpp file.

 

It would also be unclear to me if I cannot call this from inside the ACAPI_CallUndoableCommand scope of MenuCommandHandler(), how exactly would I execute my update instructions and save my work?

Currently, when I try this, I get err = -2130312312

GSErrCode __ACENV_CALL MenuCommandHandler (const API_MenuParams *params)
{
 return ACAPI_CallUndoableCommand("JHP_BatchPdf Menu Command", [&]() -> GSErrCode {
  switch (params->menuItemRef.menuResID)
  {
   case JHP_BATCHPDF_MENU_STRINGSID: {
    switch (params->menuItemRef.itemIndex)
    {
     case 1: {
      ACAPI_WriteReport("Refresh", true);
      RefreshAllLayoutBooks();
      break;
     }
     case 2: {
      ACAPI_WriteReport("Save project", true);
      Do_Save_Plan();
      break;
     }
     case 3: {
      ACAPI_WriteReport("Save PDF", true);
      Do_Save_PdfFile();
      break;
     }
    }
   }
  }
  return NoError;
 });
}



// -----------------------------------------------------------------------------
// Save the current project
// -----------------------------------------------------------------------------

static void Do_Save_Plan(void)
{
 GSErrCode err;

 err = ACAPI_Automate(APIDo_SaveID);
 if (err != NoError)
  // ACAPI_WriteReport("Error in APIDo_SaveID: %s", true, ErrID_To_Name(err));
  ACAPI_WriteReport("Error in APIDo_SaveID: %d", true, err);

 return;
} // Do_Save_Plan

 

Thanks for any hint you can provide,

Chris

 

Chris Gilmer
Intel i7-7700K CPU @ 4.20GHz
NVIDIA Quadro M4000
32.0 GB RAM
Windows 10 Pro 64-bit

Anonymous
Not applicable
In order not to open a new topic for these automated functions, how can I open a new project with the "rectangle area" in the center? I open a new project using the example and don't have it:

        API_NewProjectPars npp;

	BNZeroMemory(&npp, sizeof(API_NewProjectPars));
	npp.newAndReset = true;
	npp.enableSaveAlert = false;

	GSErrCode err = ACAPI_Automate(APIDo_NewProjectID, &npp);
	
If I manually open a new project, ARCHICAD 23 Template.tpl is choosen and everything is OK.

How can I choose this template with the automated function?

MOREH Tamas
Contributor
Hi!
You are right it is currently not possible.
I register it in our issue tracking database and we will implement as soon as we can.
Thank you for the report.

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!