Mit diesem kleinen Script ist es möglich eine beliebige Projekteigenschaft auszulesen. Es wird direkt auf die ProjectInfo.xml zugegriffen (ohne Umwege von Beschriftungen).

Anbei ein Beispielscript um die EPLAN-Version auszulesen.

Beispieltoolbar einfach importieren (Script davor laden).

 

GetProjectProperty (65)

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Windows.Forms;
using System.Xml;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;
 
public class Class
{
    [DeclareAction("GetProjectProperty")]
    public void Function(int ID)
    {
        string filename =
            PathMap.SubstitutePath("$(PROJECTPATH)" + @"\"
            + "Projectinfo.xml");
 
        string PropertyValue = ReadXml(filename,ID);
 
        MessageBox.Show(
            "Eigenschaftwert von " + ID + ":\n" +
            PropertyValue,
            "Information",
            MessageBoxButtons.OK,
            MessageBoxIcon.Information
            );
 
        return;
    }
 
    private static string ReadXml(string filename, int id)
    {
        string lastVersion = string.Empty;
        XmlTextReader reader = new XmlTextReader(filename);
        while (reader.Read())
        {
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    if (reader.Name == "id")
                    {
                        if (reader.Value == id.ToString())
                        {
                            return lastVersion = reader.ReadString();
                        }
                    }
                }
            }
        }
 
        return lastVersion;
    }
 
}