EPLAN

ShopForProcess

Heute gibt es mal eine große Ankündigung.
Seit August 2014 arbeite ich bei der Firma ibKastl als Consultant. Wir beraten Firmen bei der Installation bzw. Betreuung rund um das Thema EPLAN, Prozesse & Normen.

Mein Schwerpunkt liegt hier in der Programmierung, wie sollte es auch anders sein :^)

Wir haben zusammen mit Kunden einige praktische Scripte entwickelt und möchten diese nun auch mit allen EPLAN-Anwender teilen.

Hierfür haben wir den ShopForProcess eingerichtet und bieten dort kostenlose wie auch kostenpflichtige Scripte an.

BannerGear

Somit, falls jemand mal ein Script benötigt, aber selbst nicht programmieren kann, einfach melden und wir erstellen gerne ein Angebot.

Man könnte glauben dass es nun auf Suplanus keine Scripte mehr geben wird, das ist aber nicht der Fall. Eigentlich genau das Gegenteil. Dadurch dass ich nun wieder mehr mit Thema Scripting & EPLAN zu tun habe, entstehen viele Lösungen wie GetProjectProperty oder ScriptTest

 

Zu einigen Scripten haben wir ein Youtube-Video gemacht, um deren Funktion zu zeigen. Vielleicht ist was für den ein oder anderen dabei! Freue mich auch über jedes Feedback.

 

 

 

 

 

Von |2015-11-30T09:21:07+01:002015-02-02|EPLAN|

EPLAN Pong

Der Preis für die beste EPLAN Erweiterung geht an Daniel Papp!

Das ganze funktioniert als API-Addin und ist auf Github zu finden. Einfach klasse :^)

Von |2017-11-09T12:23:54+01:002014-11-26|EPLAN, EPLAN-API|

GetProjectProperty

Info: Es gibt eine neue Version von diesem Script.

Mit diesem Script könnt ihr einzelne Projekteigenschaften lesen.

Als Parameter habe ich mich für string entschieden, da zum Setzen der Projekteigenschaft die ID auch als String übergeben werden muss.

Verwendung:

string value = GetProjectProperty(Id, Index);

Die Methode muss im verwendeten Script vorhanden sein:

private static string GetProjectProperty(string id, string index)
{
	string value = null;
	ActionCallingContext actionCallingContext = new ActionCallingContext();
	actionCallingContext.AddParameter("id", id);
	actionCallingContext.AddParameter("index", index);
	new CommandLineInterpreter().Execute("GetProjectProperty", actionCallingContext);
	actionCallingContext.GetParameter("value", ref value);
	return value;
}

Das Script GetProjectProptery.cs laden und das Schema (GetProjectProperty_Template.xml) im Ordner Scripte/GetProjectProperty abspeichern.
Anbei das ganze Script + Download.

/* Usage
	private static string GetProjectProperty(string id, string index)
	{
		string value = null;
		ActionCallingContext actionCallingContext = new ActionCallingContext();
		actionCallingContext.AddParameter("id", id);
		actionCallingContext.AddParameter("index", index);
		new CommandLineInterpreter().Execute("GetProjectProperty", actionCallingContext);
		actionCallingContext.GetParameter("value", ref value);
		return value;
	}
*/

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

class GetProjectProperty
{
    [DeclareAction("GetProjectProperty")]
    public void Action(string id, string index, out string value)
    {
        string pathTemplate = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"),
            "GetProjectProperty", "GetProjectProperty_Template.xml");
        string pathScheme = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"),
            "GetProjectProperty", "GetProjectProperty_Scheme.xml");

        try
        {
            // Set scheme
            string content = File.ReadAllText(pathTemplate);
            content = content.Replace("GetProjectProperty_ID", id);
            content = content.Replace("GetProjectProperty_INDEX", index);
            File.WriteAllText(pathScheme, content);

            new Settings().ReadSettings(pathScheme);

            string pathOutput = Path.Combine(
                PathMap.SubstitutePath("$(MD_SCRIPTS)"), "GetProjectProperty",
                "GetProjectProperty_Output.txt");

            // Export
            ActionCallingContext actionCallingContext = new ActionCallingContext();
            actionCallingContext.AddParameter("configscheme", "GetProjectProperty");
            actionCallingContext.AddParameter("destinationfile", pathOutput);
            actionCallingContext.AddParameter("language", "de_DE");
            new CommandLineInterpreter().Execute("label", actionCallingContext);

            // Read
            value = File.ReadAllLines(pathOutput)[0];
        }
        catch (Exception exception)
        {
            MessageBox.Show(exception.Message, "GetProjectProperty", MessageBoxButtons.OK,
                MessageBoxIcon.Error);
            value = "[Error]";
        }
    }
}

GetProjectProperty auf GitHub

Von |2018-08-17T12:30:10+02:002014-11-12|EPLAN, EPLAN-Scripts|

ScriptTest

Es macht keinen Spaß Scripte zu testen… Immer wieder entladen, laden… die Fehlersuche wird somit noch schwieriger.
Ich habe lange überlegt, wie hier der Workflow optimiert werden kann.

Natürlich mit einem Script :)

Mit diesem Script, welches in EPLAN geladen werden muss, können verschiedene andere Scripte automatisch aus Visual Studio heraus in EPLAN getestet werden.

Der Ablauf ist wie folgt:

  • ScriptTest.cs in EPLAN laden
  • Visual Studio Projekt Startoptionen einstellen
  • Parameter angeben

In Visual Studio sehen die Startoptionen wie folgt aus:

Eigenschaften

C:\Program Files (x86)\EPLAN\Platform\2.4.4\Bin\EPLAN.exe
/Variant:"Electric P8" ScriptTest /parameter:'' /execute:"true" /scriptPath:"C:\Test\Script\Test.cs"

Leere Parameter müssen auch mit angegeben werden.

Hinweis für Nutzer von Visual Studio Express: Dort gibt es den Einstellungsdialog für Startoptionen nicht. Ein Workaround ist hier beschrieben.

Freu mich sehr über die Arbeitserleichterung… und darüber dass ich ein Einhorn bzw. Drache sein kann!

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

namespace ibKastl.Scripts.Test
{
    class ScriptTest
    {
        /// <summary>
        /// Start Visual Studio with the given Script
        /// </summary>
        /// <param name="scriptPath">Full Path to .cs or .vb File</param>
        /// <param name="parameter">Parameters for the Action</param>
        /// <param name="execute">Excute after EPLAN started</param>
        [DeclareAction("ScriptTest")]               
        public void Action(string scriptPath, string parameter, string execute)
        {
            // Check file
            if (!File.Exists(scriptPath))
            {
                MessageBox.Show("Scriptdatei wurde nicht gefunden:"
                                + Environment.NewLine + scriptPath + Environment.NewLine +
                                "Das Script wurde nicht geladen.",
                                "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string actionName = Path.GetFileNameWithoutExtension(scriptPath);
                CommandLineInterpreter commandLineInterpreter = new CommandLineInterpreter();

                // Unload if Action exists
                ActionCallingContext actionCallingContextUnregister = new ActionCallingContext();
                actionCallingContextUnregister.AddParameter("DontShowErrorMessage", "1");
                actionCallingContextUnregister.AddParameter("ScriptFile", scriptPath);
                commandLineInterpreter.Execute("UnregisterScript", actionCallingContextUnregister);

                // Load Script 
                ActionCallingContext actionCallingContextRegister = new ActionCallingContext();
                actionCallingContextRegister.AddParameter("ScriptFile", scriptPath);
                commandLineInterpreter.Execute("RegisterScript", actionCallingContextRegister);

                // Execute
                if (execute.ToLower().Equals("true"))
                {
                    if (!string.IsNullOrEmpty(parameter))
                    {
                        commandLineInterpreter.Execute(actionName + " " + parameter); 
                    }
                    else
                    {
                        commandLineInterpreter.Execute(actionName); 
                    }
                }
            }

        }
    }
}

ScriptTest

Von |2017-11-09T12:23:41+01:002014-10-15|EPLAN, EPLAN-Scripts|
Nach oben