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 command 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]) has been loaded via the command Load (command path: File > Extras > Command group Extensions > Interfaces > Command group Scripts > 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 command in the ribbon.
As soon as a script has been loaded once, it will automatically be loaded and ready for use the next time you start Eplan. The deactivation of such a script takes place in the Backstage view Extras via the command Unload.
See also
