Command for copiing a number of pages from the database and inserting them again into the same or another project. The selected copy mode
is taken into account and properties can be remapped during copiing.
The EPLAN.EPLAN21.PAGE.COPY command is called up via the API functions as specified in the EPLAN 21 API.
All parameters have the prefix "EPL_PARAM_PAGE_COPY_".
ParameterId | Type | Description |
---|---|---|
SOURCE | [IN] EplHandle |
Handle of an iterator over pages to be copied |
TARGET | [IN] EplHandle |
Handle of the target project to which the pages are copied |
COPYCONFIG | [IN, OPTIONAL] Integer |
ID of the copy mode configuration to use |
PROPERTYMAP | [IN, INDEX, OPTIONAL] Integer |
List of property ID's used for mapping. This is used in conjunction with MAPFROM and MAPTO. Index 0 specifies the number of values provided. Any of the properties specified here, in the pages and devices of the pages being copied, which match values stored in MAPFROM, will be mapped to the values stored in MAPTO |
MAPFROM | [IN, INDEX, OPTIONAL] String |
An indexed list of semi-colon separated values, representing the search strings for mapping properties. The index corresponds to the index in PROPERTYMAP, which specifies the ID of the property to be mapped. |
MAPTO | [IN, INDEX, OPTIONAL] String |
An indexed list of semi-colon separated values, representing the replacement strings for mapping properties. The index corresponds to the index in PROPERTYMAP, which specifies the ID of the property to be mapped. The order of the values in MAPFROM and MAPTO is important. i.e. The first value in MAPFROM is mapped to the first value in MAPTO etc. |
RESULT | [OUT, OPTIONAL] EplHandle |
A handle to an iterator containing the list of pages created in the target project. |
The eplExecuteCommand function returns EPL_OK if the symbol was successfully changed to the new symbol.
A number of different errors are possible using this comand. They are as follows:
ErrorID | Description |
---|---|
EPL_ERR_PAGE_COPY_INVALID_PAGELIST |
The page iterator passed in is not a valid page iterator. |
EPL_ERR_PAGE_COPY_INVALID_PROJECT | The project handle passed in as the target is invalid. |
EPL_ERR_PAGE_COPY_INVALID_COPYCONFIG | The index for the copy mode configuration is invalid. This error does not cause copying to be terminated but the default copy mode configuration is used. |
EPL_ERR_PAGE_COPY_UNDOLIST_PRESENT | Copying new pages into a project that is currently being used elsewhere is dangerous because it can cause data in the undo list to become invalid. The command therefore quits if it detects that an undo list for the target project is present. This can occur, for example, if the command is used from the graphical editor after the user has made some changes and before they save. |
The following example shows a function that copies a list of pages to a target project, mapping the "Plant" property (768) as follows (A1 maps to AX1, A2 maps to AX2, A3 maps to AX3) and the "Location" property (769) (O1 maps to ThirdPanelFromTheLeft).
bool copyPages(EplSession session, EplHandle dbHandle, EplHandle pageIterator, EplHandle prjHandle) { bool ret = true; EplHandle err; EplHandle cmd = eplCreateCommand(session, L"EPLAN.EPLAN21.PAGE.COPY"); err = eplSetHandleParam(session, cmd, EPL_PARAM_PAGE_COPY_SOURCE, pageIterator, 0); err = eplSetHandleParam(session, cmd, EPL_PARAM_PAGE_COPY_TARGET, prjHandle, 0); // We're mapping 2 properties, 768 and 769 err = eplSetParam(session, cmd, EPL_PARAM_PAGE_COPY_PROPERTYMAP, L"2", 0); // Index 1 is Plant (prop 768) err = eplSetParam(session, cmd, EPL_PARAM_PAGE_COPY_PROPERTYMAP, L"768", 1); // Index 2 is Location (prop 769) err = eplSetParam(session, cmd, EPL_PARAM_PAGE_COPY_PROPERTYMAP, L"769", 2); // Indices 1 of FROM and TO correspond to prop 768 err = eplSetParam(session, cmd, EPL_PARAM_PAGE_COPY_MAPFROM, L"A1;A2;A3", 1); err = eplSetParam(session, cmd, EPL_PARAM_PAGE_COPY_MAPTO, L"AX1;AX2;AX3", 1); // Note the index 2 corresponds to index 2 of PROPERTYMAP i.e. prop 769 err = eplSetParam(session, cmd, EPL_PARAM_PAGE_COPY_MAPFROM, L"O1", 2); err = eplSetParam(session, cmd, EPL_PARAM_PAGE_COPY_MAPTO, L"ThirdPanelFromTheLeft", 2); err = eplExecuteCommand(session, cmd); if (err != 0) { logger << "Page Copy command failed" << std::endl; ret = false; } eplCloseObject(session, cmd); return ret; } |