EPLAN.EPLAN21.MACRO.DXF_IMPORT

Contents

Description

Command for importing an DXF file as a temporary macro. This local copy is deleted by closeObject.

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

Parameters

All parameters have the prefix "EPL_PARAM_MACRO_DXF_IMPORT_".

ParameterID Type Description
FILENAME [IN]
String
File name of the DXF file to be imported.
SCALE [IN, OPTIONAL]
Float
Scaling factor with which the DXF file is scaled. By default, 1 is used if this parameter is lacking.
MACRO [OUT]
EplHandle
After execution of the command, this parameter can be used to query the handle of the created macro.

Error Messages

The eplExecuteCommand function returns EPL_OK if it was possible to import the DXF file as a macro.

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_MACROFILE_NOT_EXISTS The macro file does not exist.
EPL_ERR_NO_DB_OPEN There is no open database.

Example

The following example shows a function which converts a DXF file to a macro and saves it afterwards as file macro.

// Global variable for the current session
EplHandle hSession = EPL_ERROR;

// ----------------------- API-command import --------------------------------
int Import(const CString &Filename, EplHandle &hMakro)
{
        EplHandle hCmdImport = eplCreateCommand(hSession, L"EPLAN.EPLAN21.MACRO.DXF_IMPORT");

        eplSetParam(hSession,
                    hCmdImport,
                    EPL_PARAM_MACRO_DXF_IMPORT_FILENAME,
                    Filename,
                    0);

// Skaling (default is 1)
        eplSetParam(hSession,
                    hCmdImport,
                    EPL_PARAM_MACRO_DXF_IMPORT_SCALE,
                    L"0.1",
                    0);


        int ret = eplExecuteCommand(hSession, hCmdImport);
        if( ret == EPL_OK) {
                hMakro = eplGetHandleParam(hSession,
                        hCmdImport,
                        EPL_PARAM_MACRO_DXF_IMPORT_MACRO,
                        0);
        }
        eplCloseObject(hSession, hCmdImport);
        return ret;
}

// ----------------------- API-command export --------------------------------
int Export(const CString &Filename, EplHandle &hMakro)
{
        int ret = EPL_OK;
        EplHandle hCmdExport = eplCreateCommand(hSession, L"EPLAN.EPLAN21.FILE_MACRO.WRITE");

        eplSetParam(hSession,
                    hCmdExport,
                    EPL_PARAM_MACRO_WRITE_FILENAME,
                    Filename,
                    0);

        eplSetHandleParam(hSession,
                    hCmdExport,
                    EPL_PARAM_MACRO_WRITE_MACRO,
                    hMakro,
                    0);

        ret = eplExecuteCommand(hSession, hCmdExport);
        eplCloseObject(hSession, hCmdExport);
        return ret;
}

// ------------------- Check on DXF file and import it -------------------
int ImportFile(const CString &Filename)
{
        CString File;
        File = Filename + _T(".dxf");
        CFileFind finder;

        int ret = EPL_OK;
        if (finder.FindFile(File)) {
                finder.FindNextFile();
                wprintf(_T("  "));
                wprintf(Filename);
                wprintf(_T(" ... "));

                EplHandle hMakro = EPL_ERROR;

                ret = Import(Filename+".dxf", hMakro);
                if ( ret == EPL_OK) {
                        ret = Export(Filename+".mac", hMakro);
                }
                if (ret==EPL_OK) {
                        wprintf(_T("OK"));
                }
                wprintf(_T("\n"));
        }
        return ret;
}

Reference