Command for creating a part.
The EPLAN.EPLAN21.PART.CREATE command is called up via the API functions as specified in the EPLAN 21 API.
All parameters have the prefix "EPL_PARAM_PART_CREATE_".
ParameterID | Type | Description |
---|---|---|
COMPONENT | [IN, OPTIONAL] EplHandle |
Handle of a component parent object to which the new part is to be assigned (as an alternative to MACRO or PROJECT). |
PROJECT | [IN, OPTIONAL] EplHandle |
Handle of a project parent object to which the new part is to be assigned (as an alternative to MACRO or COMPONENT). |
MACRO | [IN, OPTIONAL] EplHandle |
Handle of a macro parent object to which the new part is to be assigned (as an alternative to COMPONENT or PROJECT). |
COUNT | [IN, OPTIONAL] Integer |
Number of parts to be created. By default, the value one is used if this parameter is not set. |
NUMBER | [IN] String |
Part number of the new part. |
RESULT | [OUT] EplHandle |
Contains the handle of the new part if the command has been successfully executed. |
The eplExecuteCommand function returns EPL_OK if the page could be successfully inserted into the project.
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 create a part. |
EPL_ERR_FAILED | The part could not be created. |
EPL_ERR_INVALID_ARGUMENT | The parameter COMPONENT, PROJECT, or MACRO is of the wrong type. |
The following example shows a function which creates a part which is assigned to a component. If successful, the return value of the function is the handle of the new page, otherwise EPL_ERROR.
EplHandle createComponentPart(EplSession sSession, EplHandle hComponent, const wchar_t* wcsPartNumber, long nPartCount) { EplHandle hRet(EPL_ERROR); if(hComponent) { //Create command EplHandle cmdCreatePart(eplCreateCommand(sSession, L"EPLAN.EPLAN21.PART.CREATE")); if(cmdCreatePart != EPL_ERROR) { //Set parameters //Component eplSetHandleParam(sSession, cmdCreatePart, EPL_PARAM_PART_CREATE_COMPONENT, hComponent, 0); //Part number eplSetParam(sSession, cmdCreatePart, EPL_PARAM_PART_CREATE_NUMBER, wcsPartNumber, 0); //Number of units const size_t buflen = 10; wchar_t buffer[buflen]; _ltow(nPartCount, buffer, 10); eplSetParam(sSession, cmdCreatePart, EPL_PARAM_PART_CREATE_COUNT, buffer, 0); //Execute command if( eplExecuteCommand(sSession, cmdCreatePart) != EPL_ERROR) { // Query result: hRet = eplGetHandleParam(s, cmdCreatePart, EPL_PARAM_PART_CREATE_RESULT, 0); } eplCloseObject(sSession, cmdCreatePart); } } return hRet; } |