BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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

How to close window?

Anonymous
Not applicable
GS::ErrCode err;
err = ACAPI_Automate(APIDo_CloseID,nullptr);

As result I have - error code APIERR_REFUSEDCMD

Help me please!)
6 REPLIES 6
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
See the Do_Close function of Automate_Functions example Add-On (Automate_Functions.cpp). It uses APIDo_CloseID to close the current active window.
Please note, that this function is not for public usage (as you can read in the documentation of the function also).
Anonymous
Not applicable
Sorry, it's not work.
APIERR_REFUSEDCMD error.

I need to calc change markers, that placed on the layout and in the it's drawins.
To do this I'm in cicle:
1. Opening drawing's view.
2. Collecting change markers, that placed inside drawing's margins.
3. And need to close opened view.

p. 3 is not work.
As result - many-many view windows still are opened after operation.
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Tsepov wrote:
Sorry, it's not work.
APIERR_REFUSEDCMD error.

Use it exactly the same way as in Automate_Functions.cpp, so do not forget to pass the 1234 "magic number"
err = ACAPI_Automate (APIDo_CloseID, (void *) (Int32) 1234);

Another important note (copied from the documentation):
This function performs complete operations, so it cannot be called neither during undoable operations nor during non-undoable commands.
That can be the other reason why you got that error message.
Anonymous
Not applicable
Is it possible to somehow switch to the database view of the drawing element?
This is to read items from the View in the background without opening the View window.

Now I have to use the API_DrawingLinkInfo linkGuid and
ACAPI_Automate (APIDo_GoToViewID, const char * viewGuidStr); - it is he who opens a new view window, which is then impossible to close.
Erenford
Booster
Tsepov wrote:
Is it possible to somehow switch to the database view of the drawing element?
This is to read items from the View in the background without opening the View window.

Now I have to use the API_DrawingLinkInfo linkGuid and
ACAPI_Automate (APIDo_GoToViewID, const char * viewGuidStr); - it is he who opens a new view window, which is then impossible to close.
Try
ACAPI_Database(APIDb_ChangeCurrentDatabaseID, API_DatabaseInfo* databaseInfo);
although this requires the databaseUnId of the view instead of view guid, so you have to get the API_NavigatorItem first then use its databaseinfo (API_NavigatorItem::db).
ACAPI_Navigator(APINavigator_GetNavigatorItemID, const API_Guid* guid, API_NavigatorItem* navigatorItem);
Hope this works. Also don't forget to return to the original database afterwards or else the current window might get some weird responses
Archicad 25 5010 INT FULL
Archicad 26 5002 INT FULL
Visual Studio Professional 2019
Win 10 Pro 64-bit
Anonymous
Not applicable
Thank you very much!!!!)))
It works.
You really helped me out!
Learn and get certified!