Archicad 28 C++ API
|
Functions related to the Command Scopes of Archicad. They provide a way to post Undoable and NotUndoable commands to the message loop. More...
Classes | |
class | ACAPI::ModifierBase |
Base class of every Modifier classes used in ExecuteUndoableScope/ExecuteNotUndoableScope/CallDefaultModifier function. More... | |
Functions | |
ACAPI::Result< void > ARCHICADAPI_EXPORT | ACAPI::CallUndoableCommand (const std::function< GSErrCode()> &callback, const API_Token &token, const GS::UniString &undoString) |
It executes the given callback function in an Undoable scope. | |
GSErrCode | ACAPI_Command_GetHttpConnectionPort (UShort *portNumber) |
Returns the HTTP port number, on which Archicad is expecting requests. | |
GSErrCode | ACAPI_CallUndoableCommand (const GS::UniString &undoString, const std::function< GSErrCode()> &command) |
Performs an undoable operation. | |
GSErrCode | ACAPI_CallCommand (const GS::UniString &commandName, const std::function< GSErrCode()> &command) |
Performs an operation without opening an undoable session. | |
Functions related to the Command Scopes of Archicad. They provide a way to post Undoable and NotUndoable commands to the message loop.
Archicad uses the command concept to represent and execute a user operation. All data structure modifications (except IO processes) should be performed during command execution. In case of element change notifications, the command is started, executed and managed by Archicad. Add-ons also can start and execute commands.
In case of undoable operations all modifications should be done in a lambda function which is executed by ACAPI_CallUndoableCommand.
Undoable commands can be executed only from the main thread. Use ACAPI_AddOnAddOnCommunication_CallFromEventLoop mechanism to pass the control to the main thread.
There are two possibilities to modify non-undoable data structures:
Nested command execution is forbidden: you cannot start a new command execution when an existing command is still running.
Complete operations (i.e. opening a plan) cannot be called during command execution, as they may execute several commands themselves.
Because of the command concept, new rules are introduced for API functions. The API functions are divided into four groups:
GSErrCode ACAPI_CallCommand | ( | const GS::UniString & | commandName, |
const std::function< GSErrCode()> & | command | ||
) |
Performs an operation without opening an undoable session.
commandName | [in] Reserved for further use, this string won't appear anywhere. |
command | [in] The lambda function (C++11 function wrapper) that encapsulates all the operations. |
GSErrCode ACAPI_CallUndoableCommand | ( | const GS::UniString & | undoString, |
const std::function< GSErrCode()> & | command | ||
) |
Performs an undoable operation.
undoString | [in] This string will appear after "Undo " in the Edit menu. Should be localizable. When left empty: "Paste" appears for merging and drag'n'drop operations the name of the command will be shown after "Undo " when the user chooses normal menu driven commands |
command | [in] The lambda function (C++11 function wrapper) that encapsulates the command to be called during the undoable operation. |
GSErrCode ACAPI_Command_GetHttpConnectionPort | ( | UShort * | portNumber | ) |
Returns the HTTP port number, on which Archicad is expecting requests.
portNumber | [out] HTTP port number. |
ACAPI_AddOnAddOnCommunication_InstallAddOnCommandHandler
, can be accessed. ACAPI::Result< void > ARCHICADAPI_EXPORT ACAPI::CallUndoableCommand | ( | const std::function< GSErrCode()> & | callback, |
const API_Token & | token, | ||
const GS::UniString & | undoString | ||
) |
It executes the given callback function in an Undoable scope.
callback | The function that will be executed inside the Undoable scope. |
token | The token of the add-on that is calling the command. |
undoString | The string that will be displayed in the Undo/Redo menu. |