自動アクションを単純なスクリプトに統合するオプションもあります。このような EPLAN アクションを使用して、さまざまなプログラム機能 (データのバックアップ、印刷など) を自動的に実行できます。
クラス、[Start] 属性、関数のあとにスクリプト内でアクションのパラメーター セットを指定して、CommandLineInterpreter().Execute() でアクションを実行する必要があります。
このような単純な C# スクリプトの全体的な構造は次のようになります。
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; } }
次の例に、EPLAN アクション [印刷] を含むスクリプト (C#) の例を示します。
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; } }
前述の例では、ActionCallingContext を使用して、PrintFunction 関数のパラメーター セットを指定しています。そのあとに、[印刷] アクションのさまざまなパラメーターと関連する値がリストされています。これは、たとえば NUMBER パラメーターを使用して部数を指定するのと同じ方法です。例では、ここで "1" が入力されています。[実行] を選択して [印刷] 操作を実行します。
同じ例を Visual Basic.Net で記述すると、次のようになります。
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
ヒント:
[自動処理] 機能 ([ユーティリティ] の下) も単純なスクリプトを使用してアクションを自動化します。これらのスクリプトを使用して、新規スクリプトを作成できます。メニュー アイテムの [ユーティリティ] > [スクリプト] > [実行] を使用してこれらのスクリプトを実行する前に、AutoTreat 関数の ProjectName 文字列パラメーターを、このパラメーターが使用されている行ごと削除しておく必要があります。
関連項目