Command for inserting a macro into a page.
The EPLAN.EPLAN21.MACRO.INSERT command is called up via the API functions as specified in the EPLAN 21 API.
All parameters have the prefix "EPL_PARAM_MACRO_INSERT_".
ParameterID | Type | Description |
---|---|---|
PAGE | [IN] EplHandle |
Handle of the page into which the macro is to be inserted. |
MACRO | [IN] EplHandle |
Handle of the macro which is to be inserted into the page. |
MACROPAGENR | [IN, OPTIONAL] Integer |
Index of the page to be inserted in case of multi-page macros. The first page has index 0 (default). |
XPOS | [IN, OPTIONAL] Integer |
X coordinate of the macro insertion point. Default: 0 |
YPOS | [IN, OPTIONAL] Integer |
Y coordinate of the macro insertion point. Default: 0 |
AUTONUM | [IN, OPTIONAL] Boolean |
Numbering flag. 1: The devices are automatically numbered. |
The eplExecuteCommand function returns EPL_OK if the macro could be successfully inserted into the page.
If the command fails, eplExecuteCommand returns the value EPL_ERROR. In this case, the error log can contain the following errors:
ErrorID | Description |
---|---|
EPL_ERR_NO_RIGHT | The current user group is not allowed to modify pages. |
EPL_ERR_INVALID_ARGUMENT | The handle of the page or of the macro was not valid. |
EPL_ERR_NO_MACROPAGE | The macro page does not exist. |
EPL_ERR_NO_PROJECT | The handle of the page is not managed in a project. |
EPL_ERR_FAILED | The macro could not be inserted into the page. |
The following example shows a function which inserts a macro into a page. The handles of the page and the macro must be determined first.
EplHandle insertMacro(EplSession s, EplHandle page, EplHandle macro, const wchar* wcsMacroFileName) { EplHandle hRet; //Create InsertMacro command EplHandle insertMacroCmd = eplCreateCommand(s, L"EPLAN.EPLAN21.MACRO.INSERT"); if(insertMacroCmd != EPL_ERROR) { //Set parameters //1. Set page handle eplSetHandleParam(s, insertMacroCmd, EPL_PARAM_MACRO_INSERT_PAGE, page, 0); //2. Set macro handle eplSetParam(s, insertMacroCmd, EPL_PARAM_MACRO_INSERT_MACRO, macro, 0); //3. Set X/Y coordinates of insertion point eplSetParam(s, insertMacroCmd, EPL_PARAM_MACRO_INSERT_XPOS, L"100000", 0); eplSetParam(s, insertMacroCmd, EPL_PARAM_MACRO_INSERT_YPOS, L"200000", 0); //Execute command if(eplExecuteCommand(s, insertMacroCmd) == EPL_OK) { //Query result handle: hRet = eplGetHandleParam(s, cmdCreateText, EPL_PARAM_MACRO_INSERT_RESULT, 0); } eplCloseObject(s, insertMacroCmd); } else { /* Error handling ... */ } return hRet; } |