EPLAN

EplanGetProjectVersion

Es ist ein Problem das EPLAN leider seit Jahren nicht in den Griff bekommt.

Das Projektaustauschformat ZW1 enthält keine direkte Information welche Projektversion das Projekt hat. Somit weiß man erst beim Import des Projektes ob man die richtige EPLAN Version geöffnet hat.

Hier muss man oft sehr Zeitintensiv die verschiedenen Versionen der Software öffnen/schließen.

Ich habe ein kleines Programm geschrieben, welches die ZW1-Datei prüft und die EPLAN Version anzeigt. Zusätzlich kann in einer INI-Datei hinterlegt werden, welche Versionen auf dem Rechner installiert sind. Falls die passende Version nicht installiert ist wird diese Information angezeigt:

Beispielaufbau der Settings.ini:

1.9.11	C:\Program Files (x86)\EPLAN\Electric P8\1.9.11\BIN\W3u.exe
2.0.10	C:\Program Files (x86)\EPLAN\Electric P8\2.0.10\BIN\W3u.exe
2.1.6	C:\Program Files (x86)\EPLAN\Electric P8\2.1.6\Bin\W3u.exe

Wert und Eigenschaft werden durch TABSTOP getrennt.

Ist die EPLAN Version auf dem Rechner vorhanden, wird diese gleich geöffnet. Falls nicht wird die Versionsnummer angezeigt. Bitte achtet darauf die INI-Datei zu ändern. Ich habe z.B. ein Windows 7 64bit, hier ist der Pfad zu EPLAN ein anderer als Beispielsweise unter Windows XP. Hier wird sonst ein Fehler ausgegeben.

Ich habe das Programm EplanGetProjectVersion als Standardprogramm unter Windows eingestellt. Dadurch kann ich mit einem einfachen Doppelklick die Datei öffnen bzw. die Version anzeigen lassen:

 

EplanGetProjectVersion 1.0.0 (3865 Downloads )

Projekt auf GitHub

 

using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Xml;

namespace EplanGetProjectVersion
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            try
            {
                string ProjectFile = args[0];
                const string QUOTE = "\"";
                const string NEWLINE = "\n";
                string IniFile = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\Settings.ini";
                string SevenZip = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\7za.exe";
                string TempDir = Path.GetTempPath();
                string TempFile = TempDir + "ProjectInfo.xml";
                string clArg = "e " + QUOTE + ProjectFile + QUOTE + " -o" + QUOTE + TempDir + QUOTE +
                               " ProjectInfo.xml -r";

                Console.WriteLine(
                    "==> INI file: " + IniFile + NEWLINE +
                    "==> 7zip location: " + SevenZip + NEWLINE +
                    "==> Project: " + ProjectFile + NEWLINE +
                    "==> Temp directory: " + TempDir + NEWLINE +
                    "==> Temp file: " + TempFile +
                    "==> Argument: " + clArg
                    );

                Console.WriteLine("<<< Search for 'ProjectInfo.xml'... >>>");

                // Delete tempfile
                if (File.Exists(TempFile))
                {
                    File.Delete(TempFile);
                    Console.WriteLine("==> TempFile deleted.");
                }

                // Unzip
                Console.WriteLine("<<< Arguments >>>");
                Process t7zip = new Process();
                t7zip.StartInfo.FileName = SevenZip;
                t7zip.StartInfo.Arguments = clArg;
                t7zip.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                t7zip.StartInfo.RedirectStandardOutput = true;
                t7zip.StartInfo.UseShellExecute = false;
                t7zip.EnableRaisingEvents = true;
                t7zip.Start();
                Console.WriteLine(t7zip.StandardOutput.ReadToEnd());

                // Check ProjectInfo.xml
                if (!File.Exists(TempFile))
                {
                    Console.WriteLine("==> No 'ProjectInfo.xml' found :(");
                    Console.ReadLine();
                    return;
                }

                // Search for XML property
                Console.WriteLine("<<< Search for last used version... >>>");
                string LastVersion = ReadXml(TempFile, 10043);
                Console.WriteLine("==> " + LastVersion);

                // EPLAN start
                string[] Ini = File.ReadAllLines(IniFile);
                foreach (string s in Ini)
                {
                    string[] setting = s.Split('\t');
                    if (setting[0].Equals(LastVersion))
                    {
                        Process.Start(setting[1]);
                        Console.WriteLine("==> EPLAN " + LastVersion + " started...");
                        return;
                    }
                }

                // Wait
                Console.WriteLine("==> No EPLAN " + LastVersion + " found in settings file :(");
                Console.ReadLine();
                return;
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex);
                Console.ReadLine();
            }
        }

        private static string ReadXml(string filename, int ID)
        {
            string strLastVersion;

            try
            {
                XmlTextReader reader = new XmlTextReader(filename);
                while (reader.Read())
                {
                    if (reader.HasAttributes)
                    {
                        while (reader.MoveToNextAttribute())
                        {
                            if (reader.Name == "id")
                            {
                                if (reader.Value == ID.ToString())
                                {
                                    strLastVersion = reader.ReadString();
                                    reader.Close();
                                    return strLastVersion;
                                }
                            }
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return "Property 10043 not found :(";
        }

    } // Class
} // Namespace
Von |2017-11-09T12:23:46+01:002012-08-22|EPLAN, EPLAN-Scripts|

AutoObjectSnapOnConstructionMode

Mit diesem Script wird der Objektfang gleichzeitig mit dem Konstruktionsmodus aktiviert.

Vielen Dank an FrankS für die Umsetzung!

AutoObjectSnapOnConstructionMode (2195 Downloads )

 

' GedActionToggleConstructionMode + GedToggleObjectSnapAction, Version 1.0.0, vom 27.07.2012
'
' Copyright by Frank Schöneck, 2012
'
' für Eplan Electric P8, ab V2.1.6
'
'
Public Class GedToggleObjectAction_Class

	 _
	Public Function GedActionToggleConstructionMode(ByVal iEventParameter As IEventParameter) As Long
		Dim CLI As New CommandLineInterpreter()
		CLI.Execute("XGedToggleObjectSnapAction") 'Objektfang
	End Function

End Class
Von |2017-11-09T12:23:47+01:002012-07-31|EPLAN, EPLAN-Scripts|

PagePdf

Das Script fügt einen Menüpunkt im Seitennavigator hinzu. Mit dieser Action könnt ihr ein PDF von einer oder mehrer Seiten erstellen. Alle einzelnen PDFs werden im Zielordner gespeichert. Es werden auch Ordner für Strukturkennzeichen erzeugt.

 

PagePdf (2414 Downloads )

 

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

public class PagePdf
{
    [DeclareMenu]
    public void MenuFunction()
    {
        Eplan.EplApi.Gui.ContextMenu oMenu =
            new Eplan.EplApi.Gui.ContextMenu();

        Eplan.EplApi.Gui.ContextMenuLocation oLocation =
            new Eplan.EplApi.Gui.ContextMenuLocation(
                "PmPageObjectTreeDialog",
                "1007"
                );

        oMenu.AddMenuItem(
            oLocation,
            "PDF erstellen",
            "PagePdf",
            true,
            false
            );
    }

    [DeclareAction("PagePdf")]
    public void PagePdfVoid()
    {
        FolderBrowserDialog fbd = new FolderBrowserDialog();
        CommandLineInterpreter oCLI = new CommandLineInterpreter();
        ActionCallingContext acc = new ActionCallingContext();

        if (fbd.ShowDialog() != DialogResult.OK)
        {
            return;
        }

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

        try
        {
            string strPages = string.Empty;
            acc.AddParameter("TYPE", "PAGES");
            oCLI.Execute("selectionset", acc);
            acc.GetParameter("PAGES", ref strPages);

            foreach (string CurrentPage in strPages.Split(';'))
            {
                if (!oProgress.Canceled())
                {
                    acc.AddParameter("TYPE", "PDFPAGESSCHEME");
                    acc.AddParameter("PAGENAME", CurrentPage);
                    acc.AddParameter("EXPORTFILE", fbd.SelectedPath + @"\" + CurrentPage);
                    acc.AddParameter("EXPORTSCHEME", "EPLAN_default_value");
                    oCLI.Execute("export", acc);
                }
                else
                {
                    oProgress.EndPart(true);
                    return;
                }
            }
            Process.Start(fbd.SelectedPath);
            oProgress.EndPart(true);
        }
        catch (System.Exception ex)
        {
            oProgress.EndPart(true);
            MessageBox.Show("Error", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

    }

}

 

Von |2017-11-09T12:23:47+01:002012-07-03|EPLAN, EPLAN-Scripts|
Nach oben