User supplied callback procedure for handling I/O operations.
typedef GSErrCode APIIOCommandProc ( const API_IOParams* ioParams );
Parameters
- ioParams
- [in] This structure contains the various parameters identifying the file to be opened or saved.
Return Values
NoError
- The function has completed with success.
For other common API errors see the API Errors document.
Remarks
This is the function which will be called when your add-on installed it with ACAPI_Install_FileTypeHandler.
From Archicad 19 you have to enclose the element creation creating in an undoable command scope during a merge file operation.
In case you pass empty string parameter to ACAPI_CallUndoableCommand, Archicad replaces it with the default “Paste” undo string.
From Archicad 9 merge and open operations can be initiated also with drag & drop:
- dropping a file of a registered type onto the frame window (on Windows) results an
IO_OPEN
method call - dropping a file of a registered type onto the visible client area of a drawing (floorplan, section, detail) window generates an
IO_MERGE
operation. In this case thefromDragDrop
flag of API_IOParams is set, and thedropOffset
field contains the vector that points to the dropping position from the origin.
Thefalse
value in thenoDialog
parameter means that the drag & drop operation was performed with the right mouse button or with pressing a modifier key (Ctrl on Windows, Alt on the Macintosh).
Example
// ----------------------------------------------------------------------------- // I/O command callback function // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL APIIOCommand (const API_IOParams *ioParams) { GS::UniString path; ioParams->fileLoc.ToPath (&path); switch (ioParams->method) { case IO_OPEN: DBPrintf ("Opening file \"%T\"\n", path.ToPrintf ()); // ... ACAPI_Element_Create ... break; case IO_MERGE: DBPrintf ("Merging file \"%T\"\n", path.ToPrintf ()); ACAPI_CallUndoableCommand (GS::UniString (fromDragDrop ? "Drop file" : "Merge file"), [&] () -> GSErrCode { // element.pos.x += ioParams->dropOffset.x; // element.pos.y += ioParams->dropOffset.y; // ... ACAPI_Element_Create ... }); break; case IO_SAVEAS: DBPrintf ("Saving file \"%T\"\n", path.ToPrintf ()); // ... ACAPI_Element_Get ... ACAPI_Element_ShapePrims ... break; } return NoError; } // APIIOCommand
Requirements
- Version: API 4.1 or later
- Header: APIdefs_Callback.h