Command for inserting a macro (from database) into a page.
The EPLAN.EPLAN21.DB_MACRO.INSERT command is called up via the API functions as specified in the EPLAN 21 API.
Note: This command will not be supported any longer. Please use EPLAN.EPLAN21.MACRO.INSERT
All parameters have the prefix "EPL_PARAM_DB_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] Integer |
Index of the page to be inserted in case of multi-page macros. The first page has index 0. |
XPOS | [IN] Integer |
X coordinate of the macro insertion point. |
YPOS | [IN] Integer |
Y coordinate of the macro insertion point. |
AUTONUM | [IN] Boolean |
Numbering flag 1: The devices are automatically numbered. |
REPLACESTRINGS | [IN] String |
Gives possibility to replace string. $1..n is replaced by a string. Exmp. : $1="TEST" $2="Eplan" replaces $1 with TEST and $2 with Eplan in the placed macro. |
CHECKBOUNDS | [IN] Boolean |
Flag for checking the space requirement of a macro. 1: The macro may only be placed within the page. |
NEXT_XPOS | [OUT] |
X-coordinate of the next insertion point. |
NEXT_YPOS | [OUT] |
Y coordinate of the next insertion point. |
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_NO_PROJECT | The page does not belong to any project. |
EPL_ERR_MACRO_NOT_FIT_ON_PAGE | If ..CHECKBOUNDS was set to true and the macro cannot be placed within the page. |
EPL_ERR_MACRO_INSERT_INVALID_MACROPAGENR | The transferred Makropage-Number is invalid. |
EPL_ERR_NO_PAGEHANDLE | No pagehandle was transferred. |
EPL_ERR_INVALID_PAGEHANDLE | The transferred pagehandle is invalid. |
EPL_ERR_NO_MACROHANDLE | No macrohandle was transferred. |
EPL_ERR_INVALID_MACROHANDLE | The transferred macrohandle is invalid. |
EPL_ERR_FAILED | The macro could not be inserted into the page. |
The following example shows a function that inserts a macro from the database into a page. The handles of the page and the macro must be determined first.
bool insertDBMacro(EplSession session, EplHandle hPage, EplHandle hMacro, long page_nr, long x, long y, bool do_autonum, const std::wstring& replaceString, bool checkPageBounds, long & next_x, long & next_y ) { bool retVal = false; if(hPage == EPL_ERROR) return retVal; if(hMacro == EPL_ERROR) return retVal; EplHandle insertDBMacroCmd = eplCreateCommand(session, L"EPLAN.EPLAN21.DB_MACRO.INSERT"); if(insertDBMacroCmd != EPL_ERROR) { eplSetHandleParam(session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_MACRO, hMacro, 0); eplSetHandleParam(session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_PAGE, hPage, 0); wchar_t buf[20]; _ltow(x, buf, 10); eplSetParam(session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_XPOS, buf, 0); _ltow(y, buf, 10); eplSetParam(session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_YPOS, buf, 0); _ltow(page_nr, buf, 10); eplSetParam( session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_MACROPAGENR, buf, 0 ); eplSetParam( session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_AUTONUM, do_autonum ? L"1" : L"0", 0 ); eplSetParam( session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_REPLACESTRINGS, replaceString.c_str(), 0 ); eplSetParam( session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_CHECKBOUNDS, checkPageBounds ? L"1" : L"0", 0 ); if(eplExecuteCommand(session, insertDBMacroCmd) != EPL_ERROR) { wchar_t buf[256]; retVal = true; eplGetParam( session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_NEXT_XPOS, 0, buf, 256 ); next_x = wcstol(buf, NULL, 10); eplGetParam( session, insertDBMacroCmd, EPL_PARAM_DB_MACRO_INSERT_NEXT_YPOS, 0, buf, 256 ); next_y = wcstol(buf, NULL, 10); } eplCloseObject(session, insertDBMacroCmd); } else { /* Error handling ... */ retVal = false; } return retVal; } |