EPLAN-Scripts

XGedUpdateMacroAction

Werden Makros in EPLAN über die Funktion “Makro aktualisieren” erneuert, wird leider der Wertesatz auf den Ursprungswert gesetzt.

Mit diesem Script wird der Wertesatz nicht verändert.

Die Action überschreibt die eigentlich EPLAN-Action. Da es hier zu einem Bufferoverflow kommen würde muss die eigentliche Action mit dem ActionCallingContext ausgestattet werden.

XGedUpdateMacroAction

 

XGedUpdateMacroAction (3793 Downloads )

 

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

namespace ibKastl.Scripts.Global
{
    class XGedUpdateMacroAction_Overload
    {
        [DeclareAction("XGedUpdateMacroAction", 50)] // Overwrite with ordinal
        public void Action()
        {
            ActionCallingContext actionCallingContext = new ActionCallingContext();
            actionCallingContext.AddParameter("AutoAssignLastUsedRecord", "1");
            Eplan.EplApi.ApplicationFramework.Action action = new ActionManager().FindBaseActionFromFunctionAction(false); // Full Namespace, couse of compiler warning in EPLAN
            action.Execute(actionCallingContext);
        }
    }
}
Von |2017-11-09T12:23:41+01:002015-02-24|EPLAN, EPLAN-Scripts|

InsertComment

Ein echtes Schmankerl von Frank…

Mit diesem Script können PDF-Kommentare nun auch in EPLAN platziert werden und man kann somit den Kommentarnavigator nutzen. Super im Multiuserbetrieb!

2015-02-02_21-57-48

Von |2022-01-10T08:24:48+01:002015-02-06|EPLAN, EPLAN-Scripts|

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