Alles rund um die API in EPLAN
API-Addins & Scripte auslesen
Im CAD.de-Forum gab es die Frage wie man auslesen kann welche API-Addins und Scripte geladen sind. Ich habe das mal ausprogrammiert:
using System.Windows.Forms; using Eplan.EplApi.Base; using Eplan.EplApi.Scripting; using System.Collections.Generic; using System.Collections.Specialized; public class ReadApiAddinsAndScripts { [Start] public void Action() { // API addins List<string> apiAddins = GetApiAddins(); string apiAddinsText = string.Join("\n", apiAddins); MessageBox.Show(apiAddinsText, "ApiAddins", MessageBoxButtons.OK, MessageBoxIcon.Information); // scripts List<string> scripts = GetScripts(); string scriptsText = string.Join("\n", scripts); MessageBox.Show(scriptsText, "Scripts", MessageBoxButtons.OK, MessageBoxIcon.Information); } public List<string> GetApiAddins() { List<string> list = new List<string>(); Settings settings = new Settings(); SettingNode settingsNode = new SettingNode("STATION.EplanEplApiModule.Module"); StringCollection nodes = new StringCollection(); settingsNode.GetListOfNodes(ref nodes, false); foreach (string node in nodes) { SettingNode subNode = settingsNode.GetSubNode(node); string name = subNode.GetNodePath() + ".AssemblyName"; var text = settings.GetStringSetting(name, 0); list.Add(text); } return list; } private List<string> GetScripts() { List<string> list = new List<string>(); Settings settings = new Settings(); string settingsPath = "STATION.EplanEplApiScriptGui.Scripts"; var count = settings.GetCountOfValues(settingsPath); for (var index = 0; index < count; index++) { var text = settings.GetStringSetting(settingsPath, index); list.Add(text); } return list; } }