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 scripts 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 that registers a new action. Therefore, a function is marked by the attribute  [DeclareAction]. The parameter of the attribute 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". The new action can now be used like any other action in EPLAN. For example, it can be called from the command line or assigned to a button. 

     

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

     

    To unload or unregister a script, you just call the ribbon File > ExtrasInterfacesScripts > Unload and select the respective script in the dialog: