You can load and unload scripts in EPLAN. If you do this, the start function is not executed, but rather special functions are registered in EPLAN. You can insert a new action or a menu item in EPLAN, or you can have functions registered in order to have them react to special EPLAN events.
To insert a new action in the program, the function in the script has to be identified by the [DeclareAction] attribute. Using the parameter of the [DeclareAction()] attribute, you can specify the name of the new action in EPLAN.
The overall structure of such a simple C# script thus looks like this:
public class <ScriptName> { [DeclareAction("<ActionName>")] public void <FunctionName> { //<Enter your code text here> return; } }
The following example shows a script in C# that registers a new action:
public class SimpleScriptAction { [DeclareAction("MyScriptAction")] public void MyFunctionAsAction() { MessageBox.Show("MyFunctionAsAction was called!", "RegisterScriptAction"); return; } }
If you load a script with the code listed above, the MyFunctionAsAction function in EPLAN is registered as an action with the name MyScriptAction.
The same example in Visual Basic.Net looks like this:
Public Class SimpleScriptAction <DeclareAction("MyScriptAction")> _ Public Sub MyFunctionAsAction() MessageBox.Show("MyFunctionAsAction was called!", "RegisterScriptAction") Return End Sub 'MyFunctionAsAction End Class 'SimpleScriptAction
After a corresponding script (with [DeclareAction]) is loaded using the menu item Load, the new action can be used like any other action in EPLAN. It can, for example, be called up via the command line or it can be added to a menu item or a button in a toolbar.
As soon as a script has been loaded once, it will automatically be loaded and ready for use the next time you start EPLAN. To deactivate a script of this kind, go to the menu item Unload.
See also