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 (2895 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