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

    messaYou 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 menu points to the utilities menu, 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 message as Decider = New Decider
          message.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 menu point or toolbar 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 menu point "Unload" and select the respective script in the dialog: