EPLAN-API

Alles rund um die API in EPLAN

EPLAN API: Geschachtelte Strukturen

Setzt man per EPLAN API die Strukturkennzeichen über die PagePropertyList, werden geschachtelte Strukturen (z.B. =F1.F2) nicht erkannt.

Als Workaround einfach bei den einzelnen Seiten folgendes ausführen:

page.Name = page.Name; // fix: sub name parts not recordnized by EPLAN (T1094079)

Sieht schlimm aus, darum auch bitte immer fleißig kommentieren :^)

Zu beachten: Es kann sein dass dadurch mehrere Strukturkennzeichen im Projekt erzeugt werden. Diese evtl. per Komprimierungslauf entfernen.

Von |2026-07-23T13:20:34+02:002016-10-10|EPLAN, EPLAN-API|

IEplAddInShadowCopy

EPLAN hat zur 2.6 das Verhalten geändert bzgl. Laden von DLLs.
Es wird eine Schattenkopie auf dem lokalen Client erstellt. Das hat verschiedene Vorteile (wie .NET Sicherheitsrichtlinien usw.) aber eben auch Nachteile.

Einer davon ist dass man per Reflection nicht an den Speicherort im Netzwerk kommt.

Dafür hat EPLAN zur Version 2.6 Beta 3 das Interface IEplAddInShadowCopy bereitgestellt. Hier wird der original Pfad übergeben und man kann diesen weiterverarbeiten.

void IEplAddInShadowCopy.OnBeforeInit(string originalAssemblyPath)
{
   // Do something with the original path
}

Finde schön zu sehen dass schnell auf die Bedürfnisse der User reagiert wird!

Von |2016-06-02T07:30:04+02:002016-06-02|EPLAN, EPLAN-API|

EPLAN API: UserDefinedPropertyDefinition

Die benutzerdefinierten Eigenschaften… die Idee von EPLAN war gut, aber die Umsetzung ist in meinen Augen nicht optimal.

Nichts desto Trotz müssen wir damit leben und das auch in der API. Es ist nicht ganz so einfach wie mit den „normalen“ Eigenschaften.

Ich hab hier mal paar Methoden geschrieben um (Projekt-) Eigenschaften zu Lesen/Schreiben:

using System;
using System.Linq;
using Eplan.EplApi.Base;
using Eplan.EplApi.DataModel;

namespace Suplanus.Sepla.Helper
{
	public class UserDefiniedPropertyUtility
	{
		public static PropertyValue GetProjectPropertyValueAndCheckIfEmpty(Project project, string identName)
		{
			PropertyValue propertyValue = GetProjectPropertyValue(project, identName);
			if (propertyValue.IsEmpty)
			{
				return null;
			}
			return propertyValue;
		}

		public static PropertyValue GetProjectPropertyValue(Project project, string identName)
		{
			UserDefinedPropertyDefinition userDefProp = project.Properties.ExistingIds
				.Select(anyPropertyId => anyPropertyId.Definition)
				.OfType<UserDefinedPropertyDefinition>()
				.FirstOrDefault(obj => obj.IdentifyingName.Equals(identName));
			if (userDefProp != null)
			{
				AnyPropertyId anyPropertyId = userDefProp.Id;
				PropertyValue propertyValue = project.Properties[anyPropertyId];
				return propertyValue;
			}
			return null;
		}

		public static void SetProjectPropertyValue(Project project, string identName, object value)
		{
			PropertyValue propertyValue = GetProjectPropertyValue(project, identName);
			if (propertyValue != null)
			{
				if (value is bool)
				{
					propertyValue.Set((bool)value);
					return;
				}
				if (value is double)
				{
					propertyValue.Set((double)value);
					return;
				}
				if (value is MultiLangString)
				{
					propertyValue.Set((MultiLangString)value);
					return;
				}
				if (value is PointD)
				{
					propertyValue.Set((PointD)value);
					return;
				}
				if (value is int)
				{
					propertyValue.Set((int)value);
					return;
				}
				if (value is string)
				{
					propertyValue.Set((string)value);
					return;
				}
				if (value is DateTime)
				{
					propertyValue.Set((DateTime)value);
					return;
				}

				throw new Exception("Type not supported");
			}
			throw new Exception("Property not found");
		}
	}
}

 

Von |2017-11-09T11:22:51+01:002016-03-15|EPLAN, EPLAN-API|

EPLAN API: DisplayLanguages

Ich hab mir mal ne kleine API Methode um die Anzeigesprachen zu bekommen:

public static StringCollection DisplayLanguages()
{
	using (new LockingStep())
	{
		var project = ProjectUtility.GetCurrentProject();
		ProjectSettings projectSettings = new ProjectSettings(project);
		var displayLanguagesString = projectSettings.GetStringSetting("TRANSLATEGUI.DISPLAYED_LANGUAGES", 0);

		var languages = new StringCollection();
		var displaylanguages = displayLanguagesString.Split(';')
			.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToArray(); // remove empty
		languages.AddRange(displaylanguages);

		return languages;
	}
}

Habe mich hier für ne StringCollection entschieden, da man diese oft in der API braucht (z.B. Fehlwortliste exportieren).

Von |2017-11-09T11:23:00+01:002016-03-13|EPLAN, EPLAN-API|

EPLAN API: Masterdata

Nochmals ein tolles API-Beispiel von Fritz, vielen Dank.

Arbeiten mit Formularen ist (mit dem Helper) nicht schwer!

using System.Collections.Specialized;
using Eplan.EplApi.DataModel;
using Eplan.EplApi.HEServices;

namespace Suplanus.Sepla.Helper
{
	public class MasterdataUtility
	{
		bool IsFormInProject(Project project, string formName)
		{
			return new Masterdata().get_ProjectEntries(project).Contains(formName);
		}

		bool IsFormInSystem(string formName)
		{
			return new Masterdata().SystemEntries.Contains(formName);
		}

		bool AddFormToProject(Project project, string formName)
		{
			Masterdata masterdata = new Masterdata();
			StringCollection newForms = new StringCollection();
			StringCollection projectForms = masterdata.get_ProjectEntries(project);

			if (!IsFormInSystem(formName))
			{
				return false;
			}

			if (!projectForms.Contains(formName))
			{				
				newForms.Add(formName);
				masterdata.AddToProjectEx(project, newForms);
			}
			return true;
		}
	}
}
Von |2017-11-09T11:23:07+01:002016-03-12|EPLAN, EPLAN-API|
Nach oben