API Help
EPLAN API / User Guide / API Miscellaneous / API Reports Modification Interface
In This Topic
    API Reports Modification Interface
    In This Topic

    The API Reports Modification Interface makes it possible to take influence on the result of report generation via an API action . 

    This way it is possible to filter or change the order of objects for a report. 

    Warning: when a report action is used, please don't set a filter or sort setting, because it can be inconsistent with the action. 

    Following points need to be done to in order to use the interface : 

     

    a) Create report processing action

    Any report template now contains a property where you can set a name of an action : 

     

     

     

    If an action by this name is registered in EPLAN, it is called on several occasions during report generation. 

    During these steps, you can influence the texts appearing in the report as well as the objects, which are reported and the order in which they appear. 

    The steps are distinguished by the "mode" parameter of the called action. 

     

    The action from template will be called with following parameters: 

     

    Step 1. 

    Parameters: 

    [in] "project" value: id of a project 

    [in] "mode" value: "Start" 

    [in] "objects" value: Ids of objects that will be updated (only if you UPDATE a report) 

     

    Prepare project data for this report if necessary, fill caches etc. 

     

    Step 2. 

    Parameters: 

    [in] "project" value: id of a project 

    [in] "mode" value: "ModifyObjectList" 

    [in /out] "objects" value: Ids of objects that will be evaluated separated with semicolon. 

     

    This list can be modified (not the objects themselves!). You can add or remove object ids from the list or change their order in the list 

    The parameter "objects" can be set only in mode ModifyObjectList! 

     

    Step 3. 

    Parameters: 

    [in] "project" value: id of a project 

    [in] "mode" value: "ModifyPages" 

    [in] "pages" value: ids of created pages separated with semicolon. 

     

    The created pages and their properties can be modified. 

     

    Step 4

    Parameters: 

    [in] "project" value: id of a project 

    [in] "mode" value: "Finish" 

     

    Clean up caches or undo changes from Step 1. 

     

    b) Prepare a form that will be processed

    It is recommended to use a custom form that will be processed by the action described above. 

    This will ensure that reports could be created either in 'standard' way or in the new one. 

    The simplest way is to use a copy of existing form. 

    Such form should be set in Form field of project template: 

     

     

     

    The form could have a custom actions assigned to placeholder texts . This could be set in the form editor : 

     

     

     

    Now it is necessary to create the text processing action (see bellow) 

     

    c) Create placeholder texts processing action

     

    This action will be called, when the placeholder text is evaluated during report generation. The action is called with the following parameters: 

     

    [in] "objects" value: main object for the line (can be more than one). 

    [out]: Call SetStrings() of the calling context to set the result text. More than one result text will generate new lines. 

    [in/out] "color" value: ColorId. Set the color to change color of placeholder texts. It works with one result text only. 

    Color index (0-255) Please use -16002 as "From layer" value. 

    Predefined values for line color index are: 

     

    0 = black 

    1 = red 

    2 = yellow 

    3 = green 

    4 = cyan 

    5 = blue 

    6 = magenta 

    7 = white 

    ... 

    252 = dark gray 

    253 = gray 

    ... 

     

    d) Make sure that new form is included in project master data pool

     

    This can be done using Eplan::EplApi::HEServices::Masterdata class 

    Example

    Here is an example of creating an embedded report with report processing action : 

    C#
    Copy Code
    //copy a form with placeholder texts processing action to the master data directory
    File.Copy("c:\\temp\\PlugDiagramReportActionFormular.f22", new ProjectManager().Paths.Forms + "\\PlugDiagramReportActionFormular.f22", true);
    //... and add it to project master data
    StringCollection oProjectNewEntries = new StringCollection();
    oProjectNewEntries.Add(@"PlugDiagramReportActionFormular.f22");
    System.Collections.Hashtable oResult = new Masterdata().AddToProjectEx(m_oReportActionProject, oProjectNewEntries);
    //prepare ReportBlock object
    ReportBlock oReportBlock = new ReportBlock();
    oReportBlock.Create(m_oReportActionProject);
    //set a form with a placeholder texts processing action
    oReportBlock.FormName = "PlugDiagramReportActionFormular";
    oReportBlock.Type = DocumentTypeManager.DocumentType.PlugDiagram;
    //set report processing action
    oReportBlock.Action = "PlugDiagramReportAction";
    //generate embedded report
    ReportBlockReference oReportBlockReference = new Reports().CreateEmbeddedReport(oReportBlock, oPage, new PointD(10.0, 300.0));