EPLAN

Anzeigesprache per Script ermitteln

Wie so oft ist es in der API ganz einfach… Im Scripting muss man aber einmal einen Roundtrip machen…
Hier eine Action um die Anzeigesprache des Projektes per Script zu ermitteln.

Aufruf:

public void Function()
{
  var languages = GetDisplayLanguages();
  foreach (var language in languages)
  {
    MessageBox.Show(language);
  }
  return;
}

private static List<string> GetDisplayLanguages()
{
  string value = null;
  ActionCallingContext actionCallingContext = new ActionCallingContext();
  new CommandLineInterpreter().Execute("GetDisplayLanguages", actionCallingContext);
  actionCallingContext.GetParameter("value", ref value);
  var split = value.Split(';');
  var languages = split.Where(language => !string.IsNullOrEmpty(language)).ToList();
  return languages;
}

 

Script:

using System.IO;
using System.Xml;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

namespace EplanScriptingProjectBySuplanus.GetDisplayLanguages
{
    public class GetDisplayLanguages
  {
        [DeclareAction("GetDisplayLanguages")]
        public void Action(out string value)
        {
            // Get language from settings
            string tempFile = Path.Combine(PathMap.SubstitutePath("$(TMP)"), "GetDisplayLanguages.xml");

            ActionCallingContext actionCallingContext = new ActionCallingContext();
            actionCallingContext.AddParameter("prj", FullProjectPath());
            actionCallingContext.AddParameter("node", "TRANSLATEGUI");
            actionCallingContext.AddParameter("XMLFile", tempFile);
            new CommandLineInterpreter().Execute("XSettingsExport", actionCallingContext);

            // Needed because there is no direct access to setting
            string language = GetValueSettingsXml(tempFile, "/Settings/CAT/MOD/Setting[@name='DISPLAYED_LANGUAGES']/Val");
            value = language;
        }

        private static string GetValueSettingsXml(string filename, string url)
        {
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.Load(filename);
            XmlNodeList rankListSchemaName = xmlDocument.SelectNodes(url);
            if (rankListSchemaName != null && rankListSchemaName.Count > 0)
            {
                string value = rankListSchemaName[0].InnerText;
                return value;
            }
            return null;
        }

        private static string FullProjectPath()
        {
            ActionCallingContext acc = new ActionCallingContext();
            acc.AddParameter("TYPE", "PROJECT");

            string projectPath = string.Empty;
            new CommandLineInterpreter().Execute("selectionset", acc);
            acc.GetParameter("PROJECT", ref projectPath);

            return projectPath;
        }
    }
}

 

Ihr findet das wie gewohnt auf GitHub.

Von |2019-03-14T08:30:01+01:002018-09-07|EPLAN, EPLAN-Scripts|

EPLAN Version ermitteln

Vielen Dank an nairolf für die Bereitstellung der schönen Methode um die EPLAN Version zu ermitteln. Funktioniert in API & Scripting. Man kann das dann z.B. so verwenden:

if (EplanApplicationInfo.GetActiveEplanVersion() >= 270)
{
  FlyToTheRainbowIn27();
}

Die Methode:

using System;
using System.Diagnostics;
using System.IO;
using Eplan.EplApi.Base;

namespace Suplanus.Sepla.Application
{
  public class EplanApplicationInfo
  {
    public static int GetActiveEplanVersion()
    {
      string eplanVersion = "0"; //default value = 0 to ensure, that EPLAN-version is correctly recognized 

      //try new variable $(EPLAN_VERSION) first, if not valid, no possibility to get active get active EPLAN-version
      if (PathMap.SubstitutePath("$(EPLAN_VERSION)") != "$(EPLAN_VERSION)")
      {
        eplanVersion = PathMap.SubstitutePath("$(EPLAN_VERSION)");
      }
      else
      {
        //try different method to get version of executing eplan, in case the actual version doesn't support $(EPLAN_VERSION)
        string dllFilename = Path.Combine(PathMap.SubstitutePath("$(BIN)"), "Eplan.EplApi.Baseu.dll");
        FileInfo fileInfo = new FileInfo(dllFilename);
        if (fileInfo.Exists)
        {
          var versionInfo = FileVersionInfo.GetVersionInfo(dllFilename);
          //return main-version-infos (without build number)
          if (versionInfo.ProductVersion.Length >= 5)
          {
            eplanVersion = versionInfo.ProductVersion.Substring(0, 5);
          }
        }
      }

      if (eplanVersion == "0" || eplanVersion == "$(EPLAN_VERSION)")
      {
        MultiLangString multiLangErrorText = new MultiLangString();
        multiLangErrorText.AddString(ISOCode.Language.L_de_DE, "Die aktuelle EPLAN-Version konnte nicht ermittelt werden.");
        multiLangErrorText.AddString(ISOCode.Language.L_en_US, "Unable to get actual EPLAN-version.");
        ISOCode.Language guiLanguage = new Languages().GuiLanguage.GetNumber();
        string errorText = multiLangErrorText.GetStringToDisplay(guiLanguage);
        if (String.IsNullOrEmpty(errorText))
        {
          //if actual GUI-language is not defined in multi-language-string, use en_US-text-version
          errorText = multiLangErrorText.GetStringToDisplay(ISOCode.Language.L_en_US);
        }
        new BaseException(errorText, MessageLevel.Warning).FixMessage(); 
        eplanVersion = "0";
      }
      return Convert.ToInt32(eplanVersion.Replace(".", string.Empty));
    }
  }
}

Findet Ihr auch hier auf GitHub.

Von |2022-03-28T08:08:11+02:002018-09-04|EPLAN, EPLAN-API, EPLAN-Scripts|

SyncProjects

Es gibt mal wieder ein neues Produkt von uns, was für mich in die Kategorie gehört “was man eigentlich schon immer gebraucht hätte”.
Hat man, wie es sich gehört, Basisprojekt und mindestens ein Makroprojekt, kommt man in die missliche Lage dass man die Einstellungen bei Änderungen immer über alle Projekte verteilen muss.

Das nimmt einen SyncProjects ab und verteilt folgendes:

  • Projekteinstellungen
  • Ebenen
  • Eigenschaftsanordnungen
  • Benutzerdefinierte Zusatzfelder

 

Von |2018-08-23T12:17:02+02:002018-08-23|EPLAN, ShopForProcess|

EPLAN 2.8: Scripting Neuerungen

Die Beta ist noch nicht draußen, aber die Hilfe ist schon verfügbar.

 

Entfernt

EPLAN5 und EPLAN21 Übernahme. Somit auch die Action E21EasyImportSettingAction.

 

Hinzugefügt

 

Geändert

Die Aktion generatemacros  wurde um die folgenden optionalen Parameter erweitert:

  • PAGENAMEn  : Namen der zu berücksichtigenden Seiten
  • INSTALLATIONSPACENAMEn  : Namen der zu berücksichtigenden Bauräume
  • STRUCTUREn  : Strukturkennzeichen der zu berücksichtigenden Bauräume
  • WINDOWMACRODIR  : Verzeichnis für Fenstermakros
  • PAGEMACRODIR  : Verzeichnis für Seitenmakros
  • FILTERSCHEME  : Filterschema
  • OVERWRITE  : Überschreibmodus.

Dabei steht “n” für eine Nummer.

 

Von |2018-08-17T12:32:47+02:002018-08-02|EPLAN|
Nach oben