Zum Inhalt

Beispiele

FirstSteps

Start

using Eplan.EplApi.Scripting;
using System.Windows.Forms;

namespace Namespace
{
  public class Class
  {
    [Start]
    public void Function()
    {
      MessageBox.Show("Scripting is great!"); // Comment
      return;
    }
  }
}


DeclareAction

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _01_FirstSteps_02_DeclareAction
{
  [DeclareAction("ActionName")]
  public void Function()
  {
    MessageBox.Show("Scripting is great!");
  }
}


DeclareEventHandler

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _01_FirstSteps_03_DeclareEventHandler
{
  [DeclareEventHandler("onActionStart.String.XPrjActionProjectClose")]
  public void Function()
  {
    MessageBox.Show("Scripting is great!");
  }
}


DeclareRegisterUnregister

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _01_FirstSteps_04_DeclareRegisterUnregister
{
  [DeclareRegister]
  public void Register()
  {
    MessageBox.Show("Script loaded.");
  }

  [DeclareUnregister]
  public void UnRegister()
  {
    MessageBox.Show("Script unloaded.");
  }
}

RunActions

SingleAction

using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _02_RunActions_01_SingleAction
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    cli.Execute("reports");
  }
}


MultipleActions

using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _02_RunActions_02_MultipleActions
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();

    cli.Execute("XMsgActionStartVerification");
    cli.Execute("reports");
    cli.Execute("ActionName");
  }
}


ActionsWithParameter

using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _02_RunActions_03_ActionsWithParameter
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();

    acc.AddParameter("Name", "XGedIaFormatText");
    acc.AddParameter("height", "20");

    cli.Execute("XGedStartInteractionAction", acc);
  }
}


ActionOverloading

using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;
using System.Windows.Forms;

public class _02_RunActions_04_ActionOverloading
{
  [DeclareAction("XSDShowMatchingMasterDialogAction", 50)]
  public void Function()
  {
    MessageBox.Show("Warning!");

    ActionCallingContext acc = new ActionCallingContext();
    Eplan.EplApi.ApplicationFramework.Action action =
      new ActionManager().FindBaseActionFromFunctionAction(false);    
    action.Execute(acc);
  }
}

Classes

String

using System;
using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _03_Classes_01_String
{
  [Start]
  public void Function()
  {
    MessageBox.Show("I am a text (but actually a string)!");

    string message1 = string.Empty;
    message1 = "I am a string with\nline break!";
    MessageBox.Show(message1);
    MessageBox.Show("Me" + Environment.NewLine + "too!");

    string message2 = "I am also a string!";
    MessageBox.Show(message2);
    message2 = "You can also give me a new text!";
    MessageBox.Show(message2);

    string message3_1 = "And I ";
    string message3_2 = "am one ";
    string message3_3 = "too!";
    MessageBox.Show(message3_1 + message3_2 + message3_3);

    MessageBox.Show("Line break in code " +
                    "is not displayed!");

    string message4 = "The {0} is in the {1}.";
    string message4_1 = string.Format(message4, "comb", "cabinet");
    string message4_2 = string.Format(message4, "cabinet", "bathroom");
    MessageBox.Show(message4_1);
    MessageBox.Show(message4_2);
  }
}


StringPathVariable

using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _03_Classes_02_StringPathVariable
{
  [Start]
  public void Function()
  {
    string projectName = PathMap.SubstitutePath("$(PROJECTNAME)");
    MessageBox.Show(projectName);
  }
}


Integer

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _03_Classes_03_Integer
{
  [Start]
  public void Function()
  {
    int result;
    int number1 = 6;
    int number2 = 3;

    MessageBox.Show(number1.ToString());

    result = number1 + number2;
    MessageBox.Show(result.ToString());

    result = number1 - number2;
    MessageBox.Show(result.ToString());

    result = number1 * number2;
    MessageBox.Show(result.ToString());

    result = number1 / number2;
    MessageBox.Show(result.ToString());
  }
}


ErrorInteger

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _03_Classes_04_ErrorInteger
{
  [Start]
  public void Function()
  {
    string number1String = "10";
    string number2String = "2";
    string resultString = number1String + number2String;
    MessageBox.Show(resultString);

    int result;
    int number1 = 10;
    int number2 = 0;
    result = number1 / number2;
    MessageBox.Show(result.ToString());
  }
}


Float

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _03_Classes_05_Float
{
  [Start]
  public void Function()
  {
    float result;
    float number1 = 10;
    float number2 = 3;

    result = number1 / number2;
    MessageBox.Show(result.ToString());
  }
}


ErrorFloat

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _03_Classes_06_ErrorFloat
{
  [Start]
  public void Function()
  {
    float result;
    result = 10 / 3;
    MessageBox.Show("10 / 3 = " + result.ToString());
  }
}


TryCatch

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using System;

public class _03_Classes_07_TryCatch
{
  [Start]
  public void Function()
  {
    int result;
    int number1 = 10;
    int number2 = 0;

    try
    {
      result = number1 / number2;

      // No more code is executed from here
      MessageBox.Show(result.ToString());
      MessageBox.Show("Calculation successfully completed.");
    }
    catch (Exception exception)
    {
      MessageBox.Show(exception.Message);
    }
  }
}


BaseException

using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _03_Classes_08_BaseException
{
  [Start]
  public void Function()
  {
    BaseException bexAssert = new BaseException("Assert", MessageLevel.Assert);
    bexAssert.FixMessage();

    BaseException bexError = new BaseException("Error", MessageLevel.Error);
    bexError.FixMessage();

    BaseException bexFatalError = new BaseException("FatalError", MessageLevel.FatalError);                      
    bexFatalError.FixMessage();

    BaseException bexMessage = new BaseException("Message", MessageLevel.Message);
    bexMessage.FixMessage();

    BaseException bexTrace = new BaseException("Trace", MessageLevel.Trace);
    bexTrace.FixMessage();

    BaseException bexWarning = new BaseException("Warning", MessageLevel.Warning);
    bexWarning.FixMessage();

    CommandLineInterpreter cli = new CommandLineInterpreter();
    cli.Execute("SystemErrDialog");
  }
}


ParameterString

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _03_Classes_09_ParameterString
{
  [DeclareAction("StringParameter")]
  public void Function(string parameter)
  {
    MessageBox.Show(parameter);
  }
}


ParameterInteger

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _03_Classes_10_ParameterInteger
{
  [DeclareAction("IntParameter")]
  public void Function(int int1, int int2)
  {
    int result = int1 + int2;

    string message = int1.ToString() + " + " + int2.ToString() + " = " + result.ToString();

    MessageBox.Show(message);
  }
}


MessageBox

using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _03_Classes_11_MessageBox
{
  [Start]
  public void Function()
  {
    string projectName = PathMap.SubstitutePath("$(PROJECTNAME)");

    MessageBox.Show("Text", projectName);

    MessageBox.Show("Text", projectName, MessageBoxButtons.YesNo);

    MessageBox.Show("Text", projectName, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Information);
  }
}


OwnClass

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

class _03_Classes_12_OwnClass
{
  [Start]
  public void Function()
  {
    Person john = new Person();
    john.FirstName = "John";
    john.LastName = "Doe";
    MessageBox.Show(john.FirstName + " " + john.LastName);

    Person jane = new Person("Jane", "Public");
    jane.DisplayFullName();
  }

  class Person
  {
    public string FirstName { get; set; }
    public string LastName { get; set; }

    public string FullName
    {
      get { return FirstName + " " + LastName; }
    }

    public Person()
    {
    }

    public Person(string firstName, string lastName)
    {
      FirstName = firstName;
      LastName = lastName;
    }

    public void DisplayFullName()
    {
      MessageBox.Show(FullName);
    }
  }
}

CodeFlow

IfString

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_01_IfString
{
  [DeclareAction("IfString")]
  public void Function(string parameter)
  {
    if (parameter == "YES")
    {
      MessageBox.Show("yes");
    }
    else
    {
      MessageBox.Show("no");
    }

    if (parameter.ToUpper() == "YES")
    {
      MessageBox.Show("yes");
    }
    else
    {
      MessageBox.Show("no");
    }
  }
}


ElseIf

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_02_ElseIf
{
  [Start]
  public void Function()
  {
    DialogResult result = MessageBox.Show(
        "Should the action be executed?",
        "Title",
        MessageBoxButtons.YesNoCancel,
        MessageBoxIcon.Question
        );

    if (result == DialogResult.Yes)
    {
      MessageBox.Show("Yes");
    }
    else if (result == DialogResult.No)
    {
      MessageBox.Show("No");
    }
    else if (result == DialogResult.Cancel)
    {
      MessageBox.Show("Cancel");
    }
  }
}


Switch

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_03_Switch
{
  [Start]
  public void Function()
  {
    DialogResult result = MessageBox.Show(
      "Should the action be executed?",
      "Title",
      MessageBoxButtons.YesNoCancel,
      MessageBoxIcon.Question
    );

    switch (result)
    {
      case DialogResult.Yes:
        MessageBox.Show("Yes");
        break;

      case DialogResult.No:
        goto default;

      default:
        MessageBox.Show("No or cancel");
        break;
    }
  }
}


MethodMessageBox

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_04_MethodMessageBox
{
  [DeclareAction("MethodeMessageBox")]
  public void Function(int int1, int int2)
  {
    int intResult = int1 + int2;

    MessageBox.Show(int1.ToString() +
        " + " + int2.ToString() +
        " = " + intResult.ToString());
    FinishedMessageBox();
  }

  private static void FinishedMessageBox()
  {
    MessageBox.Show("Calculation was successful.");
  }
}


MethodInteger

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_05_MethodInteger
{
  [DeclareAction("MethodeInt")]
  public void Function(int int1, int int2)
  {
    CalcMessageBox(int1, int2);
    FinishedMessageBox();
  }

  private static void CalcMessageBox(int int1, int int2)
  {
    int result = int1 + int2;
    MessageBox.Show(int1.ToString() +
        " + " + int2.ToString() +
        " = " + result.ToString());
  }

  private static void FinishedMessageBox()
  {
    MessageBox.Show("Calculation was successful.");
  }
}


MethodReturnValue

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_06_MethodReturnValue
{
  [DeclareAction("MethodReturnValue")]
  public void Function(int int1, int int2)
  {
    int result = Calc(int1, int2);

    MessageBox.Show(
        int1.ToString() +
        " + " + int2.ToString() +
        " = " + result.ToString()
        );

    FinishedMessageBox();
  }

  private static int Calc(int int1, int int2)
  {
    return int1 + int2;
  }

  private static void FinishedMessageBox()
  {
    MessageBox.Show("Calculation was successful.");
  }
}


MethodOverloading

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_07_MethodOverloading
{
  [Start]
  public void Function()
  {
    string message = string.Empty;

    message = DoSomething("Bananas");

    MessageBox.Show(message,
        "Information",
        MessageBoxButtons.OK,
        MessageBoxIcon.Information);

    message = DoSomething("Bananas", "3");

    MessageBox.Show(message,
        "Information",
        MessageBoxButtons.OK,
        MessageBoxIcon.Information);
  }

  /// <summary>
  /// Gibt einen Wert zurück, der den Satz enthält:
  /// "Ich habe gerade [food] gegessen!"
  /// </summary>
  /// <param name="food">Nahrungsmittel</param>
  private static string DoSomething(string food)
  {
    string fullMessage = "I have just eaten " + food + "!";

    return fullMessage;
  }

  /// <summary>
  /// Gibt einen Wert zurück, der den Satz enthält:
  /// "Ich habe gerade [amount] [food] gegessen!"
  /// </summary>
  /// <param name="food">Nahrungsmittel</param>
  /// <param name="amount">Menge</param>
  private static string DoSomething(string food, string amount)
  {
    return "I have just eaten " + amount + " " + food + "!";
  }
}


Decider

using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_08_Decider
{
  [Start]
  public void Function()
  {
    // OK
    Decider deciderOk = new Decider();
    deciderOk.Decide(
      EnumDecisionType.eOkDecision,
      "I say OK!",
      "Decider",
      EnumDecisionReturn.eOK,
      EnumDecisionReturn.eOK);

    // YesNo
    Decider deciderYesNo = new Decider();
    EnumDecisionReturn decisionYesNo = deciderYesNo.Decide(
      EnumDecisionType.eYesNoDecision,
      "Yes or no?",
      "Decider",
      EnumDecisionReturn.eYES,
      EnumDecisionReturn.eYES);

    switch (decisionYesNo)
    {
      case EnumDecisionReturn.eYES:
        MessageBox.Show("Yes");
        break;

      case EnumDecisionReturn.eNO:
        MessageBox.Show("No");
        break;
    }

    // YesNoAll
    Decider deciderYesNoAll = new Decider();
    EnumDecisionReturn decisionYesNoAll = deciderYesNoAll.Decide(
      EnumDecisionType.eYesAllNoAllDecision,
      "Yes or no for all?",
      "Decider",
      EnumDecisionReturn.eYES,
      EnumDecisionReturn.eYES);

    switch (decisionYesNoAll)
    {
      case EnumDecisionReturn.eYES:
        MessageBox.Show("Yes");
        break;

      case EnumDecisionReturn.eNO:
        MessageBox.Show("No");
        break;

      case EnumDecisionReturn.eYES_ALL:
        MessageBox.Show("Yes for all");
        break;

      case EnumDecisionReturn.eNO_ALL:
        MessageBox.Show("No for all");
        break;
    }

    // Icon and CheckBox
    Decider deciderIconAndCheckBox = new Decider();
    EnumDecisionReturn decisionIconAndCheckBox =
      deciderIconAndCheckBox.Decide(
        EnumDecisionType.eRetryCancelDecision,
        "Icon and CheckBox. Great, isn't it?",
        "Decider",
        EnumDecisionReturn.eRETRY,
        EnumDecisionReturn.eRETRY,
        "DecisionIconAndCheckBox",
        true,
        EnumDecisionIcon.eQUESTION);

    if (decisionIconAndCheckBox == EnumDecisionReturn.eRETRY)
    {
      MessageBox.Show("Once is enough...");
    }
  }
}


ListSelectDecisionContext

using System.Collections.Specialized;
using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _04_CodeFlow_09_ListSelectDecisionContext
{
  [Start]
  public void Function()
  {
    string title = "Will the story end?";
    string redPill = "Red pill";
    string bluePill = "Blue pill";

    StringCollection entries = new StringCollection();
    entries.Add(redPill);
    entries.Add(bluePill);

    ListSelectDecisionContext listSelectDecision = new ListSelectDecisionContext(entries, redPill, title);
    listSelectDecision.AllowMultiSelect = false;

    var result = new Decider().Decide(listSelectDecision);
    if (result == EnumDecisionReturn.eOK)
    {
      MessageBox.Show(listSelectDecision.SelectedEntry);
    }
  }
}

ActionsWithValues

ActionWithReturnValue

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _05_ActionsWithValues_01_ActionWithReturnValue
{
  [Start]
  public void Function()
  {
    string value = string.Empty;

    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext actionCallingContext = new ActionCallingContext();
    actionCallingContext.AddParameter("name", "Neo");
    cli.Execute("ReturnAction", actionCallingContext);

    actionCallingContext.GetParameter("value", ref value);

    MessageBox.Show(value);
  }

  [DeclareAction("ReturnAction")]
  public void ReturnAction(string name, out string value)
  {
    value = "Knock knock " + name;
  }
}


ActionWithActionCallingContext

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _05_ActionsWithValues_02_ActionWithActionCallingContext
{
  private ActionCallingContext _acc;

  [DeclareAction("ActionWithActionCallingContext")]
  public void ReturnAction(ActionCallingContext acc)
  {
    _acc = acc;

    string firstName = GetParameterValue("firstName");

    string message = "Hello";
    if (!string.IsNullOrWhiteSpace(firstName))
    {
      message = message + " " + firstName;

      string lastName = GetParameterValue("lastName");
      if (!string.IsNullOrWhiteSpace(lastName))
      {
        message = message + " " + lastName;
      }
    }

    MessageBox.Show(message);
  }

  private string GetParameterValue(string parameterName)
  {
    string parameter = null;
    _acc.GetParameter(parameterName, ref parameter);
    return parameter;
  }
}

Settings

SetString

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _05_Settings_01_SetString
{
  [Start]
  public void Function()
  {
    Settings settings = new Settings();

    settings.SetStringSetting("USER.TrDMProject.UserData.Identification", "TEST", 0);

    MessageBox.Show("Setting has been set.");
  }
}


SetBool

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _05_Settings_02_SetBool
{
  [Start]
  public void Function()
  {
    Settings settings = new Settings();

    settings.SetBoolSetting("USER.EnfMVC.ContextMenuSetting.ShowExtended", true, 0);

    MessageBox.Show("Setting has been activated. EPLAN restart required.");
  }
}


SetInteger

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _05_Settings_03_SetInteger
{
  [Start]
  public void Function()
  {
    Settings settings = new Settings();

    settings.SetNumericSetting("USER.SYSTEM.GUI.LAST_PROJECTS_COUNT", 11, 0);

    MessageBox.Show("Setting has been set.");
  }
}


ReadString

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _05_Settings_04_ReadString
{
  [Start]
  public void Function()
  {
    Settings settings = new Settings();

    string name = settings.GetStringSetting("USER.TrDMProject.UserData.Longname", 0);

    MessageBox.Show("Hello " + name + "!");
  }
}


ReadBool

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _05_Settings_05_ReadBool
{
  [Start]
  public void Function()
  {
    Settings settings = new Settings();

    bool useLoginName = settings.GetBoolSetting("USER.XUserSettingsGui.UseLoginName", 0);

    if (useLoginName)
    {
      MessageBox.Show("Setting is activated.");
    }
    else
    {
      MessageBox.Show("Setting is deactivated.");
    }
  }
}


ReadInteger

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _05_Settings_06_ReadInteger
{
  [Start]
  public void Function()
  {
    Settings settings = new Settings();

    int minColWidth = settings.GetNumericSetting("USER.MF.PREVIEW.MINCOLWIDTH", 0);

    MessageBox.Show("Minimum width of the tiles in the preview: "
        + minColWidth.ToString());
  }
}


Import

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _05_Settings_07_Import
{
  [Start]
  public void Function()
  {
    Settings settings = new Settings();

    settings.ReadSettings(@"C:\test\test.xml");

    MessageBox.Show("Settings have been imported.");
  }
}


ImportProjectSettings

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _08_ImportProjectSettings
{
  [Start]
  public void Function()
  {
    string scripts = PathMap.SubstitutePath("$(MD_SCRIPTS)" + @"\");
    string project = PathMap.SubstitutePath("$(P)");

    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();
    acc.AddParameter("Project", project);
    acc.AddParameter("XmlFile", scripts + @"Point.xml");
    cli.Execute("XSettingsImport", acc);

    MessageBox.Show("Settings have been imported.");
  }
}

RibbonContextMenus

Ribbon

using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Gui;
using Eplan.EplApi.Scripting;

class _07_RibbonContextMenus_01_Ribbon
{
  private const string ACTION_NAME = "RibbonAction";

  private MultiLangString TAB_NAME
  {
    get
    {
      MultiLangString tabName = new MultiLangString();
      tabName.AddString(ISOCode.Language.L_de_DE, "Mein Tab");
      tabName.AddString(ISOCode.Language.L_en_US, "My Tab");
      return tabName;
    }
  }

  [DeclareRegister]
  public void Register()
  {
    RibbonBar ribbonBar = new RibbonBar();
    RibbonTab ribbonTab = ribbonBar.GetTab(TAB_NAME, true);
    if (ribbonTab == null)
    {
      ribbonTab = ribbonBar.AddTab(TAB_NAME);
    }

    // Simple
    RibbonCommandGroup ribbonCommandGroup1 = ribbonTab.AddCommandGroup("My group 1");
    RibbonIcon ribbonIcon1 = new RibbonIcon(CommandIcon.Accumulator);
    ribbonCommandGroup1.AddCommand("My action 1", ACTION_NAME, ribbonIcon1);

    // Extended
    MultiLangString groupText = new MultiLangString();
    groupText.AddString(ISOCode.Language.L_de_DE, "Meine Gruppe 2");
    groupText.AddString(ISOCode.Language.L_en_US, "My group 2");
    RibbonCommandGroup ribbonCommandGroup2 = ribbonTab.AddCommandGroup(groupText);

    MultiLangString commandText = new MultiLangString();
    commandText.AddString(ISOCode.Language.L_de_DE, "Meine Aktion 2");
    commandText.AddString(ISOCode.Language.L_en_US, "My action 2");

    MultiLangString tooltip = new MultiLangString();
    tooltip.AddString(ISOCode.Language.L_de_DE, "Mein ToolTip");
    tooltip.AddString(ISOCode.Language.L_en_US, "My tooltip");

    MultiLangString description = new MultiLangString();
    description.AddString(ISOCode.Language.L_de_DE, "Meine Beschreibung");
    description.AddString(ISOCode.Language.L_en_US, "My description");

    string imagePath = @"C:\test\test.svg";
    RibbonIcon ribbonIcon2 = ribbonBar.AddIcon(imagePath);
    ribbonCommandGroup2.AddCommand(commandText, ACTION_NAME, tooltip, description, ribbonIcon2);
  }

  [DeclareUnregister]
  public void UnRegister()
  {
    RibbonBar ribbonBar = new RibbonBar();
    RibbonTab ribbonTab = ribbonBar.GetTab(TAB_NAME, true);
    if (ribbonTab != null)
    {
      ribbonTab.Remove();
    }
  }

  [DeclareAction(ACTION_NAME)]
  public void Function()
  {
    MessageBox.Show("Action was executed!");
  }
}


ContextMenu

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _07_RibbonContextMenus_02_ContextMenu
{
  [DeclareAction("MenuAction")]
  public void ActionFunction()
  {
    MessageBox.Show("Action was executed!");
  }

  [DeclareMenu]
  public void MenuFunction()
  {
    Eplan.EplApi.Gui.ContextMenuLocation contextMenuLocation =
        new Eplan.EplApi.Gui.ContextMenuLocation(
            "GedEditGuiText",
            "1002"
            );

    Eplan.EplApi.Gui.ContextMenu menu = 
      new Eplan.EplApi.Gui.ContextMenu();
    menu.AddMenuItem(
        contextMenuLocation,
        "Menu item in context menu",
        "MenuAction",
        true,
        false
        );
  }
}


ContextMenuId

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _07_RibbonContextMenus_03_ContextMenuId
{
  [DeclareRegister]
  public void Register()
  {
    Settings settings = new Settings();

    settings.SetBoolSetting("USER.EnfMVC.ContextMenuSetting.ShowIdentifier", true, 0);

    MessageBox.Show("Context menu id: visible");
  }

  [DeclareUnregister]
  public void UnRegister()
  {
    Settings settings = new Settings();

    settings.SetBoolSetting("USER.EnfMVC.ContextMenuSetting.ShowIdentifier", false, 0);

    MessageBox.Show("Context menu id: invisible");
  }
}

Progressbar

SimpleProgress

using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;
using System.Threading;

public class _08_Progressbar_01_SimpleProgress
{
  [Start]
  public void Function()
  {
    Progress progress = new Progress("SimpleProgress");
    progress.SetAllowCancel(true);
    progress.SetAskOnCancel(true);
    progress.SetNeededSteps(3);
    progress.SetTitle("My progress");
    progress.ShowImmediately();

    try
    {
      if (!progress.Canceled())
      {
        progress.SetActionText("Step 1");
        progress.SetTitle("Title 1");
        progress.Step(1);

        Thread.Sleep(1000);
      }

      if (!progress.Canceled())
      {
        progress.SetActionText("Step 2");
        progress.SetTitle("Title 2");
        progress.Step(1);

        Thread.Sleep(1000);
      }

      if (!progress.Canceled())
      {
        progress.SetActionText("Step 3");
        progress.SetTitle("Title 3");
        progress.Step(1);

        Thread.Sleep(1000);
      }
    }
    finally
    {
      progress.EndPart(true);
    }
  }
}


EnhancedProgress

using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _08_Progressbar_02_EnhancedProgress
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();

    Progress progress = new Progress("EnhancedProgress");
    progress.SetAllowCancel(false);
    progress.ShowImmediately();

    try
    {
      progress.BeginPart(33, "Part 1");
      cli.Execute("generate /TYPE:CONNECTIONS");
      progress.EndPart();

      progress.BeginPart(33, "Part 2");
      cli.Execute("reports");
      progress.EndPart();

      progress.BeginPart(33, "Part 3");
      cli.Execute("compress /FILTERSCHEME:Standard");
      progress.EndPart();
    }
    finally
    {
      progress.EndPart(true);
    }
  }
}

Forms

Template

using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class FormTemplate : Form
{
  public FormTemplate()
  {
    InitializeComponent();
  }

  #region Code generated by the Windows Form Designer
  private System.ComponentModel.IContainer components = null;

  protected override void Dispose(bool disposing)
  {
    if (disposing && (components != null))
    {
      components.Dispose();
    }
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
      this.SuspendLayout();
      // 
      // FormTemplate
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(284, 261);
      this.Name = "FormTemplate";
      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
      this.Text = "Template";
      this.ResumeLayout(false);

  }
  #endregion

  [Start]
  public void Function()
  {
    FormTemplate form = new FormTemplate();
    form.ShowDialog();
  }
}


FormsExample

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _09_Forms_02_FormsExample : System.Windows.Forms.Form
{
  private Button ButtonCancel;
  private Button ButtonOk;
  private CheckBox CheckBoxProjectCheck;
  private CheckBox CheckBoxReport;
  private CheckBox CheckBoxCheckAll;
  private Label LabelProject;
  private ProgressBar ProgressBarFull;

  public _09_Forms_02_FormsExample()
  {
    InitializeComponent();
  }

  #region Code generated by the Windows Form Designer

  /// <summary>
  /// Erforderliche Designervariable.
  /// </summary>
  private System.ComponentModel.IContainer components = null;

  /// <summary>
  /// Verwendete Ressourcen bereinigen.
  /// </summary>
  /// <param name="disposing">True, wenn verwaltete Ressourcen
  /// gelöscht werden sollen; andernfalls False.</param>
  protected override void Dispose(bool disposing)
  {
    if (disposing && (components != null))
    {
      components.Dispose();
    }
    base.Dispose(disposing);
  }

  /// <summary>
  /// Erforderliche Methode für die Designerunterstützung.
  /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert
  /// werden.
  /// </summary>
  private void InitializeComponent()
  {
      this.ButtonCancel = new System.Windows.Forms.Button();
      this.ButtonOk = new System.Windows.Forms.Button();
      this.CheckBoxProjectCheck = new System.Windows.Forms.CheckBox();
      this.CheckBoxReport = new System.Windows.Forms.CheckBox();
      this.CheckBoxCheckAll = new System.Windows.Forms.CheckBox();
      this.LabelProject = new System.Windows.Forms.Label();
      this.ProgressBarFull = new System.Windows.Forms.ProgressBar();
      this.SuspendLayout();
      // 
      // ButtonCancel
      // 
      this.ButtonCancel.Location = new System.Drawing.Point(207, 240);
      this.ButtonCancel.Name = "ButtonCancel";
      this.ButtonCancel.Size = new System.Drawing.Size(75, 23);
      this.ButtonCancel.TabIndex = 5;
      this.ButtonCancel.Text = "Cancel";
      this.ButtonCancel.UseVisualStyleBackColor = true;
      this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
      // 
      // ButtonOk
      // 
      this.ButtonOk.Location = new System.Drawing.Point(126, 240);
      this.ButtonOk.Name = "ButtonOk";
      this.ButtonOk.Size = new System.Drawing.Size(75, 23);
      this.ButtonOk.TabIndex = 4;
      this.ButtonOk.Text = "OK";
      this.ButtonOk.UseVisualStyleBackColor = true;
      this.ButtonOk.Click += new System.EventHandler(this.ButtonOk_Click);
      // 
      // CheckBoxProjectCheck
      // 
      this.CheckBoxProjectCheck.AutoSize = true;
      this.CheckBoxProjectCheck.Checked = true;
      this.CheckBoxProjectCheck.CheckState = System.Windows.Forms.CheckState.Checked;
      this.CheckBoxProjectCheck.Location = new System.Drawing.Point(12, 25);
      this.CheckBoxProjectCheck.Name = "CheckBoxProjectCheck";
      this.CheckBoxProjectCheck.Size = new System.Drawing.Size(75, 17);
      this.CheckBoxProjectCheck.TabIndex = 1;
      this.CheckBoxProjectCheck.Text = "Check run";
      this.CheckBoxProjectCheck.UseVisualStyleBackColor = true;
      // 
      // CheckBoxReport
      // 
      this.CheckBoxReport.AutoSize = true;
      this.CheckBoxReport.Checked = true;
      this.CheckBoxReport.CheckState = System.Windows.Forms.CheckState.Checked;
      this.CheckBoxReport.Location = new System.Drawing.Point(12, 48);
      this.CheckBoxReport.Name = "CheckBoxReport";
      this.CheckBoxReport.Size = new System.Drawing.Size(92, 17);
      this.CheckBoxReport.TabIndex = 2;
      this.CheckBoxReport.Text = "Create reports";
      this.CheckBoxReport.UseVisualStyleBackColor = true;
      // 
      // CheckBoxCheckAll
      // 
      this.CheckBoxCheckAll.AutoSize = true;
      this.CheckBoxCheckAll.Checked = true;
      this.CheckBoxCheckAll.CheckState = System.Windows.Forms.CheckState.Checked;
      this.CheckBoxCheckAll.Location = new System.Drawing.Point(12, 244);
      this.CheckBoxCheckAll.Name = "CheckBoxCheckAll";
      this.CheckBoxCheckAll.Size = new System.Drawing.Size(70, 17);
      this.CheckBoxCheckAll.TabIndex = 3;
      this.CheckBoxCheckAll.Text = "Check all";
      this.CheckBoxCheckAll.UseVisualStyleBackColor = true;
      this.CheckBoxCheckAll.CheckedChanged += new System.EventHandler(this.CheckBoxCheckAll_CheckedChanged);
      // 
      // LabelProject
      // 
      this.LabelProject.AutoSize = true;
      this.LabelProject.Location = new System.Drawing.Point(9, 9);
      this.LabelProject.Name = "LabelProject";
      this.LabelProject.Size = new System.Drawing.Size(69, 13);
      this.LabelProject.TabIndex = 5;
      this.LabelProject.Text = "Project name";
      // 
      // ProgressBarFull
      // 
      this.ProgressBarFull.Location = new System.Drawing.Point(12, 224);
      this.ProgressBarFull.Maximum = 3;
      this.ProgressBarFull.Name = "ProgressBarFull";
      this.ProgressBarFull.Size = new System.Drawing.Size(270, 10);
      this.ProgressBarFull.Step = 1;
      this.ProgressBarFull.TabIndex = 6;
      // 
      // _09_Forms_02_FormsExample
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.Controls.Add(this.ProgressBarFull);
      this.Controls.Add(this.LabelProject);
      this.Controls.Add(this.CheckBoxCheckAll);
      this.Controls.Add(this.CheckBoxReport);
      this.Controls.Add(this.CheckBoxProjectCheck);
      this.Controls.Add(this.ButtonOk);
      this.Controls.Add(this.ButtonCancel);
      this.Name = "_09_Forms_02_FormsExample";
      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
      this.Text = "Form Example";
      this.Load += new System.EventHandler(this.FormsExample_Load);
      this.ResumeLayout(false);
      this.PerformLayout();

  }

  #endregion

  [Start]
  public void Function()
  {
    _09_Forms_02_FormsExample form = new _09_Forms_02_FormsExample();
    form.ShowDialog();
  }

  private void ButtonCancel_Click(object sender, System.EventArgs e)
  {
    this.Close();
  }

  private void ButtonOk_Click(object sender, System.EventArgs e)
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();

    ProgressBarFull.PerformStep();
    if (CheckBoxProjectCheck.Checked)
    {
      cli.Execute("XMsgActionStartVerification");
    }

    ProgressBarFull.PerformStep();
    if (CheckBoxReport.Checked)
    {
      cli.Execute("reports");
    }

    ProgressBarFull.PerformStep();   
    ProgressBarFull.Value = 0;

    this.Close();
  }

  private void CheckBoxCheckAll_CheckedChanged(object sender, System.EventArgs e)
  {
    if (CheckBoxCheckAll.Checked)
    {
      CheckBoxProjectCheck.Checked = true;
      CheckBoxReport.Checked = true;
    }
    else
    {
      CheckBoxProjectCheck.Checked = false;
      CheckBoxReport.Checked = false;
    }
  }

  private void FormsExample_Load(object sender, System.EventArgs e)
  {
    LabelProject.Text = PathMap.SubstitutePath("$(PROJECTNAME)");
  }
}


Cursor

using Eplan.EplApi.Scripting;
using System.Threading;
using System.Windows.Forms;

public class _09_Forms_03_Cursor
{
  [Start]
  public void Function()
  {
    Cursor.Current = Cursors.AppStarting;
    Thread.Sleep(3000);
    Cursor.Current = Cursors.WaitCursor;
    Thread.Sleep(3000);
    Cursor.Current = Cursors.Default;
  }
}


ProjectSearch

using System;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _09_Forms_04_ProjectSearch : System.Windows.Forms.Form
{
  public string ProjectPath = string.Empty;

  #region Form
  public _09_Forms_04_ProjectSearch()
  {
    InitializeComponent();
  }

  private System.Windows.Forms.Button ButtonOK;
  private System.Windows.Forms.ListView ListViewResult;
  private System.Windows.Forms.ColumnHeader columnHeader1;
  private System.Windows.Forms.ColumnHeader columnHeader2;
  private System.Windows.Forms.ColumnHeader columnHeader3;
  private System.Windows.Forms.Button ButtonSearch;
  private System.Windows.Forms.TextBox TextBoxSearch;
  private System.Windows.Forms.StatusStrip StatusStipMain;
  private System.Windows.Forms.Button ButtonCancel;
  private ToolStripStatusLabel ToolStripLabel;

  ///
  /// Erforderliche Designervariable.
  ///
  private System.ComponentModel.IContainer components = null;

  ///
  /// Verwendete Ressourcen bereinigen.
  ///
  /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
  protected override void Dispose(bool disposing)
  {
    if (disposing && (components != null))
    {
      components.Dispose();
    }
    base.Dispose(disposing);
  }

  ///
  /// Erforderliche Methode für die Designerunterstützung.
  /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
  ///
  private void InitializeComponent()
  {
      this.ButtonOK = new System.Windows.Forms.Button();
      this.ListViewResult = new System.Windows.Forms.ListView();
      this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
      this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
      this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
      this.ButtonSearch = new System.Windows.Forms.Button();
      this.TextBoxSearch = new System.Windows.Forms.TextBox();
      this.StatusStipMain = new System.Windows.Forms.StatusStrip();
      this.ToolStripLabel = new System.Windows.Forms.ToolStripStatusLabel();
      this.ButtonCancel = new System.Windows.Forms.Button();
      this.StatusStipMain.SuspendLayout();
      this.SuspendLayout();
      // 
      // ButtonOK
      // 
      this.ButtonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
      this.ButtonOK.Location = new System.Drawing.Point(474, 274);
      this.ButtonOK.Name = "ButtonOK";
      this.ButtonOK.Size = new System.Drawing.Size(75, 23);
      this.ButtonOK.TabIndex = 6;
      this.ButtonOK.Text = "OK";
      this.ButtonOK.UseVisualStyleBackColor = true;
      this.ButtonOK.Click += new System.EventHandler(this.ButtonOK_Click);
      // 
      // ListViewResult
      // 
      this.ListViewResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
      this.ListViewResult.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader1,
            this.columnHeader2,
            this.columnHeader3});
      this.ListViewResult.FullRowSelect = true;
      this.ListViewResult.GridLines = true;
      this.ListViewResult.HideSelection = false;
      this.ListViewResult.Location = new System.Drawing.Point(12, 39);
      this.ListViewResult.Name = "ListViewResult";
      this.ListViewResult.Size = new System.Drawing.Size(618, 229);
      this.ListViewResult.Sorting = System.Windows.Forms.SortOrder.Ascending;
      this.ListViewResult.TabIndex = 10;
      this.ListViewResult.UseCompatibleStateImageBehavior = false;
      this.ListViewResult.View = System.Windows.Forms.View.Details;
      this.ListViewResult.DoubleClick += new System.EventHandler(this.ListViewResult_DoubleClick);
      // 
      // columnHeader1
      // 
      this.columnHeader1.Text = "Name";
      this.columnHeader1.Width = 76;
      // 
      // columnHeader2
      // 
      this.columnHeader2.Text = "Path";
      this.columnHeader2.Width = 89;
      // 
      // columnHeader3
      // 
      this.columnHeader3.Text = "Extension";
      this.columnHeader3.Width = 223;
      // 
      // ButtonSearch
      // 
      this.ButtonSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
      this.ButtonSearch.Enabled = false;
      this.ButtonSearch.Location = new System.Drawing.Point(530, 9);
      this.ButtonSearch.Name = "ButtonSearch";
      this.ButtonSearch.Size = new System.Drawing.Size(100, 23);
      this.ButtonSearch.TabIndex = 9;
      this.ButtonSearch.Text = "Search";
      this.ButtonSearch.UseVisualStyleBackColor = true;
      this.ButtonSearch.Click += new System.EventHandler(this.ButtonSearch_Click);
      // 
      // TextBoxSearch
      // 
      this.TextBoxSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
      this.TextBoxSearch.Location = new System.Drawing.Point(12, 11);
      this.TextBoxSearch.Name = "TextBoxSearch";
      this.TextBoxSearch.Size = new System.Drawing.Size(512, 20);
      this.TextBoxSearch.TabIndex = 8;
      this.TextBoxSearch.TextChanged += new System.EventHandler(this.TextBoxSearch_TextChanged);
      // 
      // StatusStipMain
      // 
      this.StatusStipMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStripLabel});
      this.StatusStipMain.Location = new System.Drawing.Point(0, 301);
      this.StatusStipMain.Name = "StatusStipMain";
      this.StatusStipMain.Size = new System.Drawing.Size(642, 22);
      this.StatusStipMain.TabIndex = 13;
      this.StatusStipMain.Text = "statusStrip1";
      // 
      // ToolStripLabel
      // 
      this.ToolStripLabel.Name = "ToolStripLabel";
      this.ToolStripLabel.Size = new System.Drawing.Size(627, 17);
      this.ToolStripLabel.Spring = true;
      this.ToolStripLabel.Text = "Enter search term...";
      this.ToolStripLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
      // 
      // ButtonCancel
      // 
      this.ButtonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
      this.ButtonCancel.Location = new System.Drawing.Point(555, 274);
      this.ButtonCancel.Name = "ButtonCancel";
      this.ButtonCancel.Size = new System.Drawing.Size(75, 23);
      this.ButtonCancel.TabIndex = 15;
      this.ButtonCancel.Text = "Cancel";
      this.ButtonCancel.UseVisualStyleBackColor = true;
      this.ButtonCancel.Click += new System.EventHandler(this.btnCancel_Click);
      // 
      // _09_Forms_04_ProjectSearch
      // 
      this.AcceptButton = this.ButtonSearch;
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.BackColor = System.Drawing.SystemColors.Control;
      this.ClientSize = new System.Drawing.Size(642, 323);
      this.Controls.Add(this.ButtonCancel);
      this.Controls.Add(this.StatusStipMain);
      this.Controls.Add(this.ListViewResult);
      this.Controls.Add(this.ButtonSearch);
      this.Controls.Add(this.TextBoxSearch);
      this.Controls.Add(this.ButtonOK);
      this.MaximizeBox = false;
      this.MinimizeBox = false;
      this.MinimumSize = new System.Drawing.Size(450, 200);
      this.Name = "_09_Forms_04_ProjectSearch";
      this.ShowIcon = false;
      this.ShowInTaskbar = false;
      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
      this.Text = "Project search";
      this.Load += new System.EventHandler(this._09_Forms_04_ProjectSearch_Load);
      this.StatusStipMain.ResumeLayout(false);
      this.StatusStipMain.PerformLayout();
      this.ResumeLayout(false);
      this.PerformLayout();

  }

  #endregion

  [DeclareAction("ProjectSearch")]
  public void Function()
  {
    _09_Forms_04_ProjectSearch form = new _09_Forms_04_ProjectSearch();
    form.ShowDialog();
  }

  private void _09_Forms_04_ProjectSearch_Load(object sender, System.EventArgs e)
  {
    ProjectPath = PathMap.SubstitutePath("$(MD_PROJECTS)");
    TextBoxSearch.Select();
  }

  private void btnCancel_Click(object sender, System.EventArgs e)
  {
    this.Close();
  }

  private void OpenProject(string fullProjectPath)
  {
    Cursor.Current = Cursors.WaitCursor;

    ToolStripLabel.Text = "Opening project '" + Path.GetFileNameWithoutExtension(fullProjectPath) + "'...";

    this.Update();

    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();
    acc.AddParameter("Project", fullProjectPath);
    cli.Execute("ProjectOpen", acc);

    Cursor.Current = Cursors.Default;
  }

  private void ButtonSearch_Click(object sender, System.EventArgs e)
  {
    Cursor.Current = Cursors.WaitCursor;

    ToolStripLabel.Text = "Searching project(s)...";

    ListViewResult.BeginUpdate();

    GetProjects();

    ListViewResult.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

    ListViewResult.EndUpdate();

    Cursor.Current = Cursors.Default;
  }

  private void GetProjects()
  {
    ListViewResult.Items.Clear();

    string[] result = Directory.GetFiles(ProjectPath,
      "*" + TextBoxSearch.Text + "*.el*",
      SearchOption.TopDirectoryOnly);

    foreach (string project in result)
    {
      FillListView(project);
    }

    ToolStripLabel.Text = "Projects found: " + ListViewResult.Items.Count.ToString();
  }

  private void FillListView(string fullPath)
  {
    FileInfo fileInfo = new FileInfo(fullPath);

    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
    string directory = fileInfo.Directory.ToString() + @"\";
    string extension = fileInfo.Extension;

    ListViewItem listViewItem = new ListViewItem();
    listViewItem.Text = fileNameWithoutExtension;
    listViewItem.SubItems.Add(directory);
    listViewItem.SubItems.Add(extension);
    ListViewResult.Items.Add(listViewItem);
  }

  private void ButtonOK_Click(object sender, System.EventArgs e)
  {
    GetFileNameAndOpen();
  }

  private void ListViewResult_DoubleClick(object sender, EventArgs e)
  {
    GetFileNameAndOpen();
  }

  private void GetFileNameAndOpen()
  {
    if (ListViewResult.SelectedItems.Count > 0)
    {
      string project =
            ListViewResult.SelectedItems[0].SubItems[1].Text
          + ListViewResult.SelectedItems[0].SubItems[0].Text
          + ListViewResult.SelectedItems[0].SubItems[2].Text;

      OpenProject(project);
    }

    this.Close();
  }

  private void TextBoxSearch_TextChanged(object sender, System.EventArgs e)
  {
    if (TextBoxSearch.Text == "")
    {
      ButtonSearch.Enabled = false;
    }
    else
    {
      ButtonSearch.Enabled = true;
    }
  }
}

Debug

DebugSetting

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.Base;

public class _10_Debug_01_DebugSetting
{
  [DeclareRegister]
  public void Register()
  {
    Settings settings = new Settings();

    settings.SetBoolSetting("USER.EplanEplApiScriptLog.DebugScripts", true, 0);

    MessageBox.Show("Debugging enabled");
  }

  [DeclareUnregister]
  public void UnRegister()
  {
    Settings settings = new Settings();

    settings.SetBoolSetting("USER.EplanEplApiScriptLog.DebugScripts", false, 0);

    MessageBox.Show("Debugging disabled");
  }
}


DebugTest

using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using System;
using System.Diagnostics;

public class _10_Debug_02_DebugTest
{
  [Start]
  public void Function()
  {
    if (Debugger.IsAttached)
    {
      Debugger.Break();
    }

    int result;
    int number1 = 10;
    int number2 = 0;

    if (Debugger.IsAttached)
    {
      Debug.WriteLine(number1 + ":" + number2);
    }

    try
    {
      result = number1 / number2;

      // No more code is executed from here
      MessageBox.Show(result.ToString());
      MessageBox.Show("Calculation successfully completed.");
    }
    catch (Exception exception)
    {
      MessageBox.Show(exception.Message);
    }
  }
}

ExternalApplications

RunProcess

using System;
using System.Diagnostics;
using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _11_ExternalApplications_01_RunProcess
{
  [Start]
  public void Function()
  {
    try
    {
      Process.Start("calc");
    }
    catch (Exception ex)
    {
      MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
  }
}


RunMultipleProcesses

using System;
using System.Diagnostics;
using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Gui;
using Eplan.EplApi.Scripting;

public class _11_ExternalApplications_02_RunMultipleProcesses
{
  [DeclareAction("StartProcess")]
  public void Function(string processName, string parameter)
  {
    try
    {
      parameter = PathMap.SubstitutePath(parameter);
      Process.Start(processName, parameter);
    }
    catch (Exception ex)
    {
      MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
  }

  private MultiLangString TAB_NAME
  {
    get
    {
      MultiLangString tabName = new MultiLangString();
      tabName.AddString(ISOCode.Language.L_de_DE, "Mein Tab");
      tabName.AddString(ISOCode.Language.L_en_US, "My Tab");
      return tabName;
    }
  }

  private const string GROUP_NAME = "Apps";

  [DeclareUnregister]
  public void UnRegister()
  {
    RibbonBar ribbonBar = new RibbonBar();
    RibbonTab ribbonTab = ribbonBar.GetTab(TAB_NAME, true);
    if (ribbonTab != null)
    {
      RibbonCommandGroup ribbonCommandGroup = ribbonTab.GetCommandGroup(GROUP_NAME);
      if (ribbonCommandGroup != null)
      {
        ribbonCommandGroup.Remove();
      }
    }
  }

  [DeclareRegister]
  public void Register()
  {
    RibbonBar ribbonBar = new RibbonBar();

    RibbonTab ribbonTab = ribbonBar.GetTab(TAB_NAME, true);
    if (ribbonTab == null)
    {
      ribbonTab = ribbonBar.AddTab(TAB_NAME);
    }

    RibbonCommandGroup ribbonCommandGroup = ribbonTab.AddCommandGroup(GROUP_NAME);

    string quote = "\"";

    ribbonCommandGroup.AddCommand("Calculator",
      "StartProcess /processName:calc /parameter:''",
      new RibbonIcon(CommandIcon.Application));

    ribbonCommandGroup.AddCommand(
      "Project folder",
      "StartProcess /processName:explorer /parameter:" +
      quote +"$(PROJECTPATH)" + quote,
      new RibbonIcon(CommandIcon.Application));

    ribbonCommandGroup.AddCommand("Char map",
      "StartProcess /processName:charmap /parameter:''",
      new RibbonIcon(CommandIcon.Application));

    string pdfFile = @"C:\test\test.pdf";
    ribbonCommandGroup.AddCommand("PDF", 
      "StartProcess /processName:" + quote + pdfFile + quote +
      " /parameter:''",
      new RibbonIcon(CommandIcon.Application));
  }
}

FilesFolders

CheckFolder

using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _12_FilesFolders_01_CheckFolder
{
  [Start]
  public void Function()
  {
    string path = @"C:\test\";

    if (Directory.Exists(path))
    {
      MessageBox.Show("Folder already exists.");
    }
    else
    {
      Directory.CreateDirectory(path);
      MessageBox.Show("Folder created.");
    }
  }
}


CheckFile

using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _12_FilesFolders_02_CheckFile
{
  [Start]
  public void Function()
  {
    string fileName = @"C:\test\test.txt";

    if (File.Exists(fileName))
    {
      MessageBox.Show("File already exists.");
    }
    else
    {
      FileStream fileStream = File.Create(fileName);
      fileStream.Dispose();
      MessageBox.Show("File created.");
    }
  }
}


DeleteFile

using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _12_FilesFolders_03_DeleteFile
{
  [Start]
  public void Function()
  {
    string fileName = @"C:\test\test.txt";

    if (File.Exists(fileName))
    {
      File.Delete(fileName);
      MessageBox.Show("File deleted.");
    }
  }
}


FileWithDateTimeStamp

using System;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _12_FilesFolders_04_FileWithDateTimeStamp
{
  [Start]
  public void Function()
  {
    string date = DateTime.Now.ToString("yyyy-MM-dd");
    string time = DateTime.Now.ToString("HH-mm-ss");
    string fileName = @"C:\test\test_" + date + "_" + time + ".txt";

    FileStream fileStream = File.Create(fileName);
    fileStream.Dispose();
    MessageBox.Show("File created.");
  }
}

FilesOpenSave

SaveFileDialog

using System;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _13_FilesOpenSave_01_SaveFileDialog
{
  [Start]
  public void Function()
  {
    string projectPath = PathMap.SubstitutePath("$(PROJECTPATH)");
    string fileName = "Test-file";

    SaveFileDialog sfd = new SaveFileDialog();
    sfd.DefaultExt = "txt";
    sfd.FileName = fileName;
    sfd.Filter = "Text files (*.txt)|*.txt";
    sfd.InitialDirectory = projectPath;
    sfd.Title = "Select storage location for test file:";
    sfd.ValidateNames = true;

    if (sfd.ShowDialog() == DialogResult.OK)
    {
      FileStream fileStream = File.Create(sfd.FileName);
      fileStream.Dispose();
      MessageBox.Show(
        "File was saved successfully:" + Environment.NewLine +
        sfd.FileName,
        "Information",
        MessageBoxButtons.OK,
        MessageBoxIcon.Information
      );
    }
  }
}


OpenFileDialog

using System;
using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _13_FilesOpenSave_02_OpenFileDialog
{
  [Start]
  public void Function()
  {
    string projectPath = PathMap.SubstitutePath("$(PROJECTPATH)");
    string fileName = "Test-file";

    OpenFileDialog ofd = new OpenFileDialog();
    ofd.DefaultExt = "txt";
    ofd.FileName = fileName;
    ofd.Filter = "Test-File (*Test-File*.txt)|*Test-File*.txt|All files (*.*)|*.*";
    ofd.InitialDirectory = projectPath;
    ofd.Title = "Choose Test-File:";
    ofd.ValidateNames = true;

    if (ofd.ShowDialog() == DialogResult.OK)
    {
      fileName = ofd.FileName;
      MessageBox.Show(
        "The storage location was successfully transferred:" +
        Environment.NewLine +
        fileName,
        "Information",
        MessageBoxButtons.OK,
        MessageBoxIcon.Information
      );
    }
  }
}


CheckFilenames

using System;
using System.Windows.Forms;
using Eplan.EplApi.Scripting;

public class _13_FilesOpenSave_03_CheckFilenames
{
  [Start]
  public void Function()
  {
    string invalidChars = @"[\\/:*?""<>|]";

    MessageBox.Show("These characters are converted:" + 
      Environment.NewLine + invalidChars,
        "Information",
        MessageBoxButtons.OK,
        MessageBoxIcon.Information);

    invalidChars = AdjustPath(invalidChars);

    MessageBox.Show(invalidChars,
        "Information",
        MessageBoxButtons.OK,
        MessageBoxIcon.Information);
  }

  private string AdjustPath(string input)
  {
    return System.Text.RegularExpressions.Regex.Replace(input, @"[\\/:*?""<>|]", "-");
  }
}


FileSelectDecisionContext

using System;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _13_FilesOpenSave_04_FileSelectDecisionContext
{
  [Start]
  public void Function()
  {
    string projectPath = PathMap.SubstitutePath("$(PROJECTPATH)");

    // Save
    FileSelectDecisionContext fsdcSave = new FileSelectDecisionContext();
    fsdcSave.Title = "Choose file:";
    fsdcSave.OpenFileFlag = false;
    fsdcSave.CustomDefaultPath = projectPath;
    fsdcSave.AllowMultiSelect = false;
    fsdcSave.DefaultExtension = "txt";
    fsdcSave.AddFilter("Text files (*.txt)", "*.txt");
    fsdcSave.AddFilter("All files (*.*)", "*.*");

    Decider deciderSave = new Decider();
    EnumDecisionReturn decisionSave = deciderSave.Decide(fsdcSave);
    if (decisionSave == EnumDecisionReturn.eCANCEL)
    {
      return;
    }

    string fullFileNameSave = fsdcSave.GetFiles()[0];
    FileStream fileStream = File.Create(fullFileNameSave);
    fileStream.Dispose();
    MessageBox.Show("File has been saved:" + Environment.NewLine + fullFileNameSave);

    // Open
    FileSelectDecisionContext fsdcOpen = new FileSelectDecisionContext();
    fsdcOpen.Title = "Choose file:";
    fsdcOpen.OpenFileFlag = true;
    fsdcOpen.CustomDefaultPath = projectPath;
    fsdcOpen.AllowMultiSelect = false;
    fsdcOpen.DefaultExtension = "txt";
    fsdcOpen.AddFilter("Text files (*.txt)", "*.txt");
    fsdcOpen.AddFilter("All files (*.*)", "*.*");

    Decider deciderOpen = new Decider();
    EnumDecisionReturn decisionOpen = deciderOpen.Decide(fsdcOpen);
    if (decisionOpen == EnumDecisionReturn.eCANCEL)
    {
      return;
    }

    string fullFileNameOpen = fsdcOpen.GetFiles()[0];
    MessageBox.Show("File openend:" + Environment.NewLine + fullFileNameOpen);
  }
}

FilesWrite

TextFileWrite

using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _14_FilesWrite_01_TextFileWrite
{
  [Start]
  public void Function()
  {
    string fileName = PathMap.SubstitutePath(@"$(PROJECTPATH)\Test-file.txt");

    StringBuilder sb = new StringBuilder();
    sb.Append("Example");
    sb.Append(" text");
    sb.AppendLine();
    sb.Append("with multiple lines");

    File.WriteAllText(fileName, sb.ToString(), Encoding.Unicode);

    MessageBox.Show(
        "Text file exported successfully.",
        "Information",
        MessageBoxButtons.OK,
        MessageBoxIcon.Information
        );

    Process.Start(fileName);
  }
}


XmlWrite

using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
using System.Xml;

public class _14_FilesWrite_02_XmlWrite
{
  [Start]
  public void Function()
  {
    List<Person> persons = new List<Person>();

    Person max = new Person("John", "Doe", "Munich", "Marienplatz 1");
    persons.Add(max);

    Person maria = new Person("Jane", "Public", "Nuremberg", "Zeppelinfeld 2");
    persons.Add(maria);

    string xmlPath = PathMap.SubstitutePath("$(MD_XML)");
    string fileName = Path.Combine(xmlPath, "Persons.xml");

    WriteXml(persons, fileName);
    MessageBox.Show("XML-file created");
  }

  public static void WriteXml(List<Person> persons, string fileName)
  {
    XmlSerializer serializer = new XmlSerializer(typeof(List<Person>));
    XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();

    XmlWriterSettings settings = new XmlWriterSettings();
    settings.Indent = true;
    settings.Encoding = Encoding.UTF8;
    XmlWriter writer = XmlWriter.Create(fileName, settings);

    serializer.Serialize(writer, persons, namespaces);
    writer.Close();
    writer.Dispose();
  }

  public class Person
  {
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public AddressClass Address { get; set; }

    public string FullName
    {
      get { return FirstName + " " + LastName; }
    }

    public Person()
    {
    }

    public Person(string firstName, string lastName,
      string city, string street)
    {
      FirstName = firstName;
      LastName = lastName;

      Address = new AddressClass();
      Address.City = city;
      Address.Street = street;
    }

    public class AddressClass
    {
      [XmlAttribute]
      public string City { get; set; }

      [XmlAttribute]
      public string Street { get; set; }
    }
  }
}

FilesRead

TextFileRead

using System.IO;
using System.Text;
using System.Windows.Forms;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _15_FilesRead_01_TextFileRead
{
  [Start]
  public void Function()
  {
    string fileName = PathMap.SubstitutePath(@"$(PROJECTPATH)\Test-file.txt");

    string[] lines = File.ReadAllLines(fileName, Encoding.Unicode);

    MessageBox.Show(lines[0]);
  }
}


XmlFileRead

using System;
using System.Windows.Forms;
using System.Xml;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _15_FilesRead_02_XmlFileRead
{
  [Start]
  public void Function()
  {
    string fileName = PathMap.SubstitutePath("$(PROJECTPATH)" + @"\" + "Projectinfo.xml");
    int id = 10043;
    string lastVersion = ReadProjectProperty(fileName, id);

    if (lastVersion != null)
    {
      MessageBox.Show("Last used EPLAN version:" + Environment.NewLine + lastVersion);
    }
    else
    {
      MessageBox.Show(
        "Property " + id + " not found.",
        "Warning",
        MessageBoxButtons.OK,
        MessageBoxIcon.Warning
      );
    }
  }

  private static string ReadProjectProperty(string fileName, int id)
  {
    string property = null;

    XmlTextReader reader = new XmlTextReader(fileName);

    while (reader.Read())
    {
      if (reader.HasAttributes)
      {
        while (reader.MoveToNextAttribute())
        {
          if (reader.Name == "id")
          {
            if (reader.Value == id.ToString())
            {
              property = reader.ReadString();
              reader.Close();
              return property;
            }
          }
        }
      }
    }

    reader.Close();
    return property;
  }
}


XmlFileOwnClassRead

using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using System.Xml.Serialization;

public class _15_FilesRead_03_XmlFileOwnClassRead
{
  [Start]
  public void Function()
  {
    string xmlPath = PathMap.SubstitutePath("$(MD_XML)");
    string fileName = Path.Combine(xmlPath, "Persons.xml");

    List<Person> persons = ReadXml(fileName);
    foreach (Person person in persons)
    {
      MessageBox.Show(person.FullName);
    }
  }

  public static List<Person> ReadXml(string fileName)
  {
    XmlSerializer serializer = new XmlSerializer(typeof(List<Person>));
    StreamReader reader = new StreamReader(fileName);

    List<Person> persons = (List<Person>)serializer.Deserialize(reader);
    reader.Close();
    reader.Dispose();
    return persons;
  }

  public class Person
  {
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public AddressClass Address { get; set; }

    public string FullName
    {
      get { return FirstName + " " + LastName; }
    }

    public Person()
    {
    }

    public class AddressClass
    {
      [XmlAttribute]
      public string City { get; set; }

      [XmlAttribute]
      public string Street { get; set; }
    }
  }
}

Export

Label

using System;
using System.IO;
using System.Runtime.Remoting.Contexts;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _16_Export_01_Label
{
  [Start]
  public bool AutoTreat()
  {
    Progress progress = new Progress("SimpleProgress");
    progress.SetAllowCancel(true);
    bool bResult = true;
    int nActionsPercent = 100;
    progress.BeginPart(nActionsPercent, "");
    nActionsPercent = 100;
    if (!progress.Canceled())
    {
      progress.BeginPart(nActionsPercent / 2, "label");
      ActionCallingContext context1 = new ActionCallingContext();
      context1.AddParameter("configscheme", "Summarized parts list");
      context1.AddParameter("filterscheme", "");
      context1.AddParameter("sortscheme", "");
      context1.AddParameter("language", "de_DE");
      context1.AddParameter("destinationfile", @"$(DOC)\BOM.xlsx");
      context1.AddParameter("recrepeat", "1");
      context1.AddParameter("taskrepeat", "1");
      context1.AddParameter("showoutput", "1");
      context1.AddParameter("type", "PROJECT");
      bResult &= new CommandLineInterpreter().Execute("label", context1);
      progress.EndPart();
    }
    nActionsPercent = 100;
    if (!progress.Canceled())
    {
      progress.BeginPart(nActionsPercent / 2, "label");
      ActionCallingContext context2 = new ActionCallingContext();
      context2.AddParameter("configscheme", "Device tag list");
      context2.AddParameter("filterscheme", "");
      context2.AddParameter("sortscheme", "");
      context2.AddParameter("language", "de_DE");
      context2.AddParameter("destinationfile", @"$(DOC)\Device-List.xlsx");
      context2.AddParameter("recrepeat", "1");
      context2.AddParameter("taskrepeat", "1");
      context2.AddParameter("showoutput", "1");
      context2.AddParameter("type", "PROJECT");
      bResult &= new CommandLineInterpreter().Execute("label", context2);
      progress.EndPart();
    }
    progress.EndPart(true);
    return bResult;
  }
}


LabelWithCheck

using System;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _16_Export_02_LabelWithCheck
{
  [Start]
  public void Function()
  {
    string fileName;

    fileName = GetFileName(@"$(DOC)\BOM.xlsx");
    if (fileName != null)
    {
      ActionCallingContext context1 = new ActionCallingContext();
      context1.AddParameter("configscheme", "Summarized parts list");
      context1.AddParameter("filterscheme", "");
      context1.AddParameter("sortscheme", "");
      context1.AddParameter("language", "de_DE");
      context1.AddParameter("destinationfile", fileName);
      context1.AddParameter("recrepeat", "1");
      context1.AddParameter("taskrepeat", "1");
      context1.AddParameter("showoutput", "1");
      context1.AddParameter("type", "PROJECT");
      new CommandLineInterpreter().Execute("label", context1);
    }

    fileName = GetFileName(@"$(DOC)\Device-List.xlsx");
    if (fileName != null)
    {
      ActionCallingContext context2 = new ActionCallingContext();
      context2.AddParameter("configscheme", "Device tag list");
      context2.AddParameter("filterscheme", "");
      context2.AddParameter("sortscheme", "");
      context2.AddParameter("language", "de_DE");
      context2.AddParameter("destinationfile", fileName);
      context2.AddParameter("recrepeat", "1");
      context2.AddParameter("taskrepeat", "1");
      context2.AddParameter("showoutput", "1");
      context2.AddParameter("type", "PROJECT");
      new CommandLineInterpreter().Execute("label", context2);
    }
  }

  private static string GetFileName(string fileName)
  {
    string projectPath = PathMap.SubstitutePath("$(PROJECTPATH)");
    string fullFileName = PathMap.SubstitutePath(fileName);

    if (File.Exists(fullFileName))
    {
      DialogResult dialogResult = MessageBox.Show(
        "The file already exists: '" +
        fullFileName +
        Environment.NewLine +
        Environment.NewLine +
        "Do you want to override it?",
        "Label",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question
      );

      if (dialogResult == DialogResult.No)
      {
        SaveFileDialog sfd = new SaveFileDialog();
        sfd.DefaultExt = "xlsx";
        sfd.FileName = fileName;
        sfd.Filter = "Excel files (*.xlsx)|*.xlsx";
        sfd.InitialDirectory = projectPath;
        sfd.Title = "Choose location for " + fileName + " :";
        sfd.ValidateNames = true;

        DialogResult sfdDialogResult = sfd.ShowDialog();
        if (sfdDialogResult == DialogResult.OK)
        {
          fullFileName = sfd.FileName;
        }
        else if (sfdDialogResult == DialogResult.Cancel)
        {
          fullFileName = null;
        }
      }
    }
    return fullFileName;
  }
}


PdfOnClosing

using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _16_Export_03_PdfOnClosing
{
  [DeclareEventHandler("Eplan.EplApi.OnUserPreCloseProject")]
  public void Function()
  {
    string path = PathMap.SubstitutePath("$(DOC)");
    string projectName = PathMap.SubstitutePath("$(PROJECTNAME)");

    DialogResult dialogResult = MessageBox.Show(
        "Do you want export a PDF for project '" +
        projectName + "' ?",
        "PDF-Export",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question
        );

    if (dialogResult == DialogResult.Yes)
    {
      Progress progress = new Progress("SimpleProgress");
      progress.SetAllowCancel(true);
      progress.SetAskOnCancel(true);
      progress.BeginPart(100, "");
      progress.ShowImmediately();

      CommandLineInterpreter cli = new CommandLineInterpreter();
      ActionCallingContext acc = new ActionCallingContext();

      string fullFileName = Path.Combine(path, projectName);
      acc.AddParameter("TYPE", "PDFPROJECTSCHEME");
      acc.AddParameter("EXPORTFILE", fullFileName);
      acc.AddParameter("EXPORTSCHEME", "EPLAN_default_value");

      cli.Execute("export", acc);

      progress.EndPart(true);
    }
  }
}

Parts

CountParts

using System.Linq;
using System.Windows.Forms;
using Eplan.EplApi.MasterData;
using Eplan.EplApi.Scripting;

class _17_Parts_01_CountParts
{
  [Start]
  public void Function()
  {
    MDPartsManagement mdPartsManagement = new MDPartsManagement();
    int partCount;

    using (MDPartsDatabase database = mdPartsManagement.OpenDatabase())
    {
      partCount = database.Parts
                            .Count(obj => obj.ProductSubGroup ==
                              MDPartsDatabaseItem.Enums.ProductSubGroup.MotorOverloadSwitch);
    }
    MessageBox.Show("Count motor overload switches: " + partCount);
  }
}


ChangePartProperties

using Eplan.EplApi.MasterData;
using Eplan.EplApi.Scripting;
using System.Linq;

class _17_Parts_02_ChangePartProperties
{
  [Start]
  public void Function()
  {
    MDPartsManagement mdPartsManagement = new MDPartsManagement();
    using (MDPartsDatabase database = mdPartsManagement.OpenDatabase())
    {
      var parts = database.Parts
                        .Where(obj => obj.ProductSubGroup ==
                          MDPartsDatabaseItem.Enums.ProductSubGroup
                          .MotorOverloadSwitch);

      foreach (MDPart part in parts)
      {
        part.Properties.ARTICLE_DESCR1 = "Motor overload switch";
      }
    }
  }
}

AdditionalExamples

Compress

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_01_Compress
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();

    acc.AddParameter("CONFIGSCHEME", "Remove unnecessary project data");

    cli.Execute("compress", acc);

    MessageBox.Show("Action executed.");
  }
}


ChangeLayer

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_02_ChangeLayer
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();

    acc.AddParameter("LAYER", "EPLAN400");
    acc.AddParameter("TEXTHEIGHT", "10");

    cli.Execute("changeLayer", acc);

    MessageBox.Show("Action executed.");
  }
}


Edit

using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_03_Edit
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();

    acc.AddParameter("DEVICENAME", "=GAA+A1-FCC1");

    cli.Execute("edit", acc);
  }
}


ExecuteScript

using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_04_ExecuteScript
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();

    acc.AddParameter("ScriptFile", @"C:\Test\01_Start.cs");

    cli.Execute("ExecuteScript", acc);
  }
}


ProjectAction

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_05_ProjectAction
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();

    acc.AddParameter("Project", @"C:\Test\Beispielprojekt.elk");
    acc.AddParameter("Action", "reports");
    acc.AddParameter("NOCLOSE", "1");

    cli.Execute("ProjectAction", acc);

    MessageBox.Show("Action executed.");
  }
}


XEsSetProjectPropertyAction

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_06_XEsSetProjectPropertyAction
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();

    acc.AddParameter("PropertyId", "10013");
    acc.AddParameter("PropertyIndex", "0");
    acc.AddParameter("PropertyValue", "23542");

    cli.Execute("XEsSetProjectPropertyAction", acc);

    MessageBox.Show("Action executed.");
  }
}


Backup

using System;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_07_Backup
{
  [Start]
  public void Function()
  {
    string projectsPath = PathMap.SubstitutePath("$(MD_PROJECTS)");
    string projectName = PathMap.SubstitutePath("$(PROJECTNAME)");

    string date = DateTime.Now.ToString("yyyy-MM-dd");
    string time = DateTime.Now.ToString("HH-mm-ss");

    string backupDirectory = Path.Combine(projectsPath, "Backup");
    string backupFileName = projectName + "_" +
      date + "_" + time + ".zw1";
    string backupFullFileName = 
      Path.Combine(backupDirectory, backupFileName);

    if (!Directory.Exists(backupDirectory))
    {
      Directory.CreateDirectory(backupDirectory);
    }

    Progress progress = new Progress("SimpleProgress");
    progress.SetAllowCancel(true);
    progress.SetAskOnCancel(true);
    progress.BeginPart(100, "");
    progress.SetTitle("Backup");
    progress.ShowImmediately();

    if (!progress.Canceled())
    {
      CommandLineInterpreter cli = new CommandLineInterpreter();
      ActionCallingContext acc = new ActionCallingContext();

      acc.AddParameter("BACKUPAMOUNT", "BACKUPAMOUNT_ALL");
      acc.AddParameter("BACKUPMEDIA", "DISK");
      acc.AddParameter("BACKUPMETHOD", "BACKUP");
      acc.AddParameter("COMPRESSPRJ", "1");
      acc.AddParameter("INCLEXTDOCS", "1");
      acc.AddParameter("INCLIMAGES", "1");
      acc.AddParameter("ARCHIVENAME", backupFileName);
      acc.AddParameter("DESTINATIONPATH", backupDirectory);
      acc.AddParameter("TYPE", "PROJECT");

      cli.Execute("backup", acc);
    }

    progress.EndPart(true);

    MessageBox.Show(
        "Backup was created successfully:" +
        Environment.NewLine +
        backupFullFileName,
        "Information",
        MessageBoxButtons.OK,
        MessageBoxIcon.Information
        );
  }
}


Restore

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_08_Restore
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();

    acc.AddParameter("TYPE", "PROJECT");
    acc.AddParameter("ARCHIVENAME", @"C:\test\Beispielprojekt.zw1");
    acc.AddParameter("PROJECTNAME", @"C:\test\Beispielprojekt.elk");
    acc.AddParameter("UNPACKPROJECT", "0");
    acc.AddParameter("MODE", "1");
    acc.AddParameter("NOCLOSE", "1");

    cli.Execute("restore", acc);

    MessageBox.Show("Action executed.");
  }
}


ProjectManagement

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class _99_AdditionalExamples_09_ProjectManagement
{
  [Start]
  public void Function()
  {
    string projectsPath = PathMap.SubstitutePath("$(MD_PROJECTS)");

    OpenFileDialog ofd = new OpenFileDialog();
    ofd.Filter = "ProjectInfo.xml|ProjectInfo.xml";
    ofd.InitialDirectory = projectsPath;
    ofd.Title = "Choose project properties file:";
    ofd.ValidateNames = false;

    if (ofd.ShowDialog() == DialogResult.OK)
    {
      Progress progress = new Progress("SimpleProgress");
      progress.SetAllowCancel(false);
      progress.BeginPart(100, "");
      progress.SetTitle("Import project properties");
      progress.ShowImmediately();

      CommandLineInterpreter cli = new CommandLineInterpreter();
      ActionCallingContext acc = new ActionCallingContext();

      acc.AddParameter("TYPE", "READPROJECTINFO");
      acc.AddParameter("FILENAME", ofd.FileName);
      cli.Execute("projectmanagement", acc);

      progress.EndPart(true);

      cli.Execute("XPrjActionPropertiesEdit");
    }
  }
}


SelectionSet

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;

class _99_Additional_10_SelectionSet
{
  [Start]
  public void Function()
  {
    CommandLineInterpreter cli = new CommandLineInterpreter();
    ActionCallingContext acc = new ActionCallingContext();
    acc.AddParameter("TYPE", "PAGES");
    cli.Execute("selectionset", acc);

    string pagesString = string.Empty;
    acc.GetParameter("PAGES", ref pagesString);

    string[] pages = pagesString.Split(';');
    int pagesCount = pages.Length;

    MessageBox.Show("Count of selected files: " + pagesCount);
  }
}

RemoteClient

using Eplan.EplApi.RemoteClient;
using System;
using System.Collections.Generic;
using System.Linq;

namespace EPLAN_Remote_Client
{
  internal class Program
  {
    static void Main(string[] args)
    {
      List<EplanServerData> instancesActive = GetInstances();
      if (instancesActive.Any())
      {
        Console.WriteLine("Start active instance...");
        EplanServerData eplanInstanceActive = instancesActive.OrderBy(obj => obj.EplanVersion).Last();

        Execute(eplanInstanceActive);
      }
      else
      {
        Console.WriteLine("No active instance found.");
      }

      Console.WriteLine("Execution completed.");
      Console.ReadKey();
    }

    public static List<EplanServerData> GetInstances()
    {
      EplanRemoteClient eplanRemoteClient = new EplanRemoteClient();
      List<EplanServerData> eplanServerDatas = new List<EplanServerData>();
      eplanRemoteClient.GetActiveEplanServersOnLocalMachine(out eplanServerDatas);
      return eplanServerDatas;
    }

    private static void Execute(EplanServerData eplanServerData)
    {
      EplanRemoteClient eplanRemoteClient = new EplanRemoteClient();
      eplanRemoteClient.SynchronousMode = true;
      eplanRemoteClient.Connect("localhost", eplanServerData.ServerPort.ToString(), new TimeSpan(0, 0, 0, 5));

      eplanRemoteClient.ExecuteAction("ActionName");
      eplanRemoteClient.Disconnect();
      eplanRemoteClient.Dispose();
    }
  }
}