Archicad C++ API
About Archicad add-on development using the C++ API.

How to close ArchiCAD file?

Anonymous
Not applicable
I tried to close file 2 ways.
1. By Name:

IO::Location loc(fileName); //fileName has _bstr_t type
IO::File file(loc);
file.Close(); // return NoError
2. Close current project:

ACAPI_Automate(APIDo_CloseID); //return APIERR_REFUSEDCMD
But nothing happens. I have no ideas about closing now.
4 REPLIES 4
Karl Ottenstein
Moderator
I have never tried any of these, but noticed that CloseID says it will not close if another add-on is active. I wonder if APIDb_CloseWindowID on the plan window would work, although the docs seem to indicate that this function is only for a 'custom window opened from the same add-on'.

I would have thought that a goodie or automate function would have been the answer.

Ralph? 😉

Karl
One of the forum moderators
AC 28 USA and earlier   •   macOS Sonoma 14.7.1, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable
Hi, Karl

I tried next code:
API_WindowInfo windowInfo;
BNZeroMemory (&windowInfo, sizeof (API_WindowInfo));
windowInfo.typeID = APIWind_FloorPlanID; // and try APIWind_WorksheetID typeId also
windowInfo.index = 1;
GSErrCode err = ACAPI_Database (APIDb_CloseWindowID, &windowInfo);
But APIERR_REFUSEDPAR error code returns.
Ralph Wessel
Mentor
equilibrium wrote:
I tried to close file 2 ways.
1. By Name:
I haven't tried to explicitly close a project. I've used the method for opening a project, which implicitly closes the current project. Why do you want to close a project without opening another?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
I haven't tried to explicitly close a project. I've used the method for opening a project, which implicitly closes the current project. Why do you want to close a project without opening another?
Hi, Ralph

My Add-On monitors project file folder for changes. When file changed, monitor should make some actions with him and show some message boxes in ArchiCAD too.
Typically ArchiCAD not lock project file all time. But I try to close project to guarantee file not locked by ArchiCAD and my monitor works right.

I can to open template project for closing current, but it's need some seconds. I will try to find decision, for example ask user to close again.

Thanks a lot