Eplan Platform API
EPLAN API / User Guide / API Framework / Scripts / Loading a script
In This Topic
    Loading a script
    In This Topic

    You can load (and unload) a script in EPLAN. In this case, not the start function is executed, but special functions are registered in EPLAN. You can add a new Action to EPLAN, add ribbon Buttons to the Extension-Ribbon->API command group, and register functions to react on EPLAN events.

               
    The following example shows a script which registers a new action. Therefore a function is marked by the attribute [DeclareAction]. The attribute's parameter defines the name of the new action in EPLAN. 
    public class SimpleScriptAction
    {
         [DeclareAction("MyScriptAction")]
         public void MyFunctionAsAction()
         {
               new Decider().Decide(EnumDecisionType.eOkDecision, "MyFunctionAsAction was called!", "RegisterScriptAction", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK);
               return;
         }
    }
    
    Public Class SimpleScriptAction
    
       <DeclareAction("MyScriptAction")>  _
       Public Sub MyFunctionAsAction()
          Dim dec As Decider = New Decider
          dec.Decide(EnumDecisionType.eOkDecision, "MyFunctionAsAction was called!", "RegisterScriptAction", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK)
       End Sub 'MyFunctionAsAction
    End Class 'SimpleScriptAction
    

     

    When a script with the above code is loaded, the function "MyFunctionAsAction" is registered in EPLAN as action by the name "MyScriptAction". Now the new action can be used like any other action in EPLAN. It can e.g. be called by the command line or it can be assigned to a button. 

     

    Once the script was loaded, it will be automatically loaded during the Startup of EPLAN and the action will again be available. 

     

    To unload (unregister) a script, you just call the ribbon "File", "Extras", "Interfaces", "Scripts" > "Unload" and select the respective script in the dialog: