You also have the option of integrating automatic actions in a simple script. Using these EPLAN actions you can automatically run different program functions (e.g. Back up data, Print, etc.).
After the class, the [Start] attribute and the function, you have to specify the parameter set for the action in the script and then run the action via CommandLineInterpreter().Execute().
The overall structure of such a simple C# script thus looks like this:
public class <ScriptName> { [Start] public void <FunctionName> { ActionCallingContext <ActionName>Context = new ActionCallingContext (); <ActionName>Context .AddParameter("<ActionParameter1>","<Value>"); <ActionName>Context .AddParameter("<ActionParameter2>","<Value>"); ... new CommandLineInterpreter().Execute("<ActionName>",<ActionName>Context); return; } }
The following example shows a script in C# with the EPLAN action Print:
public class PrintScript { [Start] public void PrintFunction() { ActionCallingContext printContext = new ActionCallingContext (); printContext .AddParameter("NUMBER","1"); printContext .AddParameter("PRINTCHANGEDPAGES","0"); printContext .AddParameter("PRINTREVERSE","0"); printContext .AddParameter("PRINTCOLLATE","0"); printContext .AddParameter("PRINTERNAME",@"\\FUEMON\Kyocera FS-1700+ TechDok KX"); printContext .AddParameter("PROJECTNAME",@"C:\Program Files\EPLAN\Electric P8\Projects\EPLAN\ESS_Sample_Project.elk); printContext .AddParameter("TYPE","PAGES"); printContext .AddParameter("PAGENAME","=GB1+A1&EFS1/1"); new CommandLineInterpreter().Execute("print",printContext); return; } }
Using ActionCallingContext the parameter set for the PrintFunction function is specified in the example above. Then the different parameters and the associated values for the Print action are listed. This is how you specify the number of copies, for example, using the NUMBER parameter. In the example, the value "1" is entered here. Select Execute to run the Print action.
The same example in Visual Basic.Net looks like this:
Public Class PrintScript { <Start> _ Public Sub PrintFunction() Dim printContext As New ActionCallingContext () printContext .AddParameter("NUMBER","1") printContext .AddParameter("PRINTCHANGEDPAGES","0") printContext .AddParameter("PRINTREVERSE","0") printContext .AddParameter("PRINTCOLLATE","0") printContext .AddParameter("PRINTERNAME", "\\FUEMON\Kyocera FS-1700+ TechDok KX") printContext .AddParameter("PROJECTNAME", "C:\Program Files\EPLAN\Electric P8\Projects\EPLAN\ESS_Sample_Project.elk) printContext .AddParameter("TYPE","PAGES") printContext .AddParameter("PAGENAME",""=GB1+A1&EFS1/1") Dim commandLineInterpreter As New CommandLineInterpreter() CommandLineInterpreter.Execute("print",printContext) Return End Sub 'PrintFunction End Class 'PrintScript
Tip:
The Automated processing function (under Utilities) uses simple scripts to automate actions. You can use these scripts to create new scripts. Before you can run these scripts using the menu items Utilities > Scripts > Run, you first have to remove the String ProjectName parameter for the AutoTreat function along with the line where this parameter is used.
See also