Eplan Platform API
EPLAN API / User Guide / API Framework / Add-ins / Actions / Calling actions
In This Topic
    Calling actions
    In This Topic

    All ribbon buttons in P8 are linked to an action. This means that when a ribbon button is called, the corresponding action is executed. In order to execute an action via EPLAN API, you have to create an  Action  object and execute the action with the  Execute  method. 

    In order to create an  Action  object, you need to know the action by its name. You have to create a new  ActionManager  object and call the  FindAction  function, which takes the name of the action as parameter. 

    To pass and evaluate action parameters, you need the  ActionCallingContext  class: 

    String strAction = "TestAction";
    ActionManager oAMnr= new ActionManager();
    Action oAction= oAMnr.FindAction(strAction);
    if (oAction != null)
    {
        ActionCallingContext ctx = new ActionCallingContext();
        bool bRet=oAction.Execute(ctx);
        if (bRet)
        {               
        new Decider().Decide(EnumDecisionType.eOkDecision, "The Action " + strAction + " ended successfully!", "", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK);
        }
        else
        {
        new Decider().Decide(EnumDecisionType.eOkDecision, "The Action " + strAction + " ended with errors!", "", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK);
        }
    }
    
    Dim strAction As String = "TestAction"
    Dim oAMnr As New ActionManager()
    Dim oAction As Action = oAMnr.FindAction(strAction)
    Dim dec As Decider = New Decider
    If Not (oAction Is Nothing) Then
       Dim ctx As New ActionCallingContext()
       Dim bRet As Boolean = oAction.Execute(ctx)
       If bRet Then
          dec.Decide(EnumDecisionType.eOkDecision, "The Action " + strAction + " ended successfully!", "", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK)              
       Else
          dec.Decide(EnumDecisionType.eOkDecision, "The Action " + strAction + " ended with errors!", "", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK)
       End If
    End If
    

     

    To find out which action is linked to which ribbon button, you can evaluate the  onActionStart.String.*  event. Alternatively, after clicking the ribbon button, press [Ctrl] + [VK_OEM_5] to show the Diagnostics Dialog. [VK_OEM_5] corresponds to the [^] key on a German keyboard or to the [\] on a United States 101 keyboard. 

    For a list of automatic actions, refer to the topic "Automatic Actions".

     

    Important: 

    Please mind that an action may modify the  ActionCallingContext  during its execution. For example, sometimes project IDs are added to the context and are passed to an inner action. Reusing the same  ActionCallingContext  for another action call may lead to unexpected results. So in most cases it is advisable to create a new  ActionCallingContext  for a new action call. 

     

    Command line call

    To extend the EPLAN command line with new commands and parameters, you need to implement an action. The action can have its own parameters and can call other API functions. 

    In this way an action is executed just after starting EPLAN, for example: 

     

    EPLAN.EXE /Variant:"Electric P8" /NoLoadWorkspace action /Param1:value1 /Param2:value2 /Param3:value3 

     

    The parameter without a flag (/  or  -) is interpreted as the name of an action to be executed. All following parameters are passed to the action. Only one action is allowed per command line call. 

    A script can also contain and register an action. This means that it can also evaluate action parameters. 

     

    It is necessary to pass more general command line parameters before the action name. 

     

    List of general command line parameters evaluated by EPLAN:

    Parameter 
    Description 
    /Variant 
    Select the product variant you want to start. E.g. "Electric P8" or "Fluid" 
    /NoLoadWorkspace 
    No workspace is loaded or restored.
    /NoSplash 
    No splash screen is shown on system start. 
    /Language:en_us 
    EPLAN is started with GUI language "English". The language predefined in the settings of EPLAN will not be changed. 
    /Auto 
    EPLAN is shut down after executing the command line. 
    /Quiet 
    No dialogs are shown while a command line is being executed. 
    /Frame:0 
    • /Frame:0 ➔ The EPLAN main frame is invisible
    • /Frame:1 ➔ The EPLAN main frame is restored to its original size and position
    • /Frame:2 ➔ The EPLAN main frame is started minimized
    • /Frame:3 ➔ The EPLAN main frame is started maximized
    /Setup 
    All Settings are restored to their installation default 
    <action name> 
    The action will be executed, all following parameters (starting with  /  or  ) are passed to the action as parameters. 

    Any command line parameter after the action name is passed as parameter to the action. The parameters are wrapped into an  ActionCallingContext  as string parameters and can be extracted by the action. Please note that the parameter names on the command line and in the  ActionCallingContext  must be spelled in the exactly the same: 

     

    EPLAN.EXE /Variant:"Electric P8" action /Param1:value1 /Param2:value2 /Param3:value3 

    public bool Execute(ActionCallingContext ctx )
    {
       String strParamValue1=null;
       ctx.GetParameter("Param1", ref strParamValue1);
       String strParamValue2=null;
       ctx.GetParameter("Param2", ref strParamValue2);
       String strParamValue3=null;
       ctx.GetParameter("Param3", ref strParamValue3);
       return true;
    }
    
    Public Function Execute(ctx As ActionCallingContext) As Boolean Implements IEplAction
       Dim strParamValue1 As String = Nothing
       ctx.GetParameter("Param1", strParamValue1)
       Dim strParamValue2 As String = Nothing
       ctx.GetParameter("Param2", strParamValue2)
       Dim strParamValue3 As String = Nothing
       ctx.GetParameter("Param3", strParamValue3)
       Return True
    End Function 'Execute
    

     Warning: When starting EPLAN from the command line with an action, then no previously opened projects are opened at the beginning of the session.

    See Also

    API Miscellaneous