EPLAN.EPLAN21.MACRO.COPY

Contents

Description

Command for taking a local copy of a macro. The local copy is deleted by closeObject. On this copy string replacements EPLAN.EPLAN21.MACRO.REPLACEPROPS can for example be carried out, before the macro will be inserted into a page EPLAN.EPLAN21.MACRO.INSERT. A local macro copy can be made of a database macro, a file macro, or from several instances.

The EPLAN.EPLAN21.MACRO.COPY command is called up via the API functions as specified in the EPLAN 21 API.

Parameters

All parameters have the prefix "EPL_PARAM_MACRO_COPY_"!

ParameterID Type Description
SOURCEMACRO [IN]
EplHandle
Handle of the macro which is to be copied. The other parameters are of no importance if EplHandle was set.
SOURCEFILENAME [IN, OPTIONAL]
String
Name of macro file of which a local macro copy is to be made. Is only evaluated if SOURCEMACRO is not set. In this case, the other parameters are of no importance.
INSTANCES [IN, OPTIONAL]
EplHandle
Handle of an iterator for instances from which the macro is to be created. Is only evaluated if SOURCEMACRO and SOURCEFILENAME are not set. Only in this case the other parameters are of importance.
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).
PAGE [IN, OPTIONAL]
EplHandle
Handle of the page whose (project) properties the macro is to adopt.
RESULT [OUT]
EplHandle
Handle of the local macro.

Error Messages

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_INVALID_ARGUMENT The instances are not available.
EPL_ERR_INVALID_PAGEHANDLE Invalid page handle.
EPL_ERR_MACRO_COPY_INVALID_INSTANCE_ITERATOR Invalid instance iterator

Example

The following example shows a function which copies a database macro. The handle of the macro must be determined first.


EplHandle copyMacro( EplSession hSession, EplHandle  macHandle )
{
        EplHandle hRet(EPL_ERROR);
        if( macHandle == EPL_ERROR )
                return hRet;
        EplHandle hCopyMacroCmd = eplCreateCommand(hSession, L"EPLAN.EPLAN21.MACRO.COPY");
        if( hCopyMacroCmd != EPL_ERROR )
        {
                eplSetHandleParam( hSession, hCopyMacroCmd,
                                       EPL_PARAM_MACRO_COPY_SOURCEMACRO, macHandle, 0 );
                if(eplExecuteCommand(hSession, hCopyMacroCmd) == EPL_OK)
                {
                        // Get the handle of the copied macro
                        hRet = eplGetHandleParam(hSession, hCopyMacroCmd,
                                                EPL_PARAM_MACRO_COPY_RESULT, 0);
                }
                eplCloseObject(hSession, hCopyMacroCmd);

        }
        return hRet;
}


Reference