EPLAN

Graphicallayertable

Endlich ist es möglich per Scripting Ebenen zu manipulieren. Ich hätte mir zwar gewünscht das für einzelne Ebenen zu zun, aber so ist das mit dem kleinen Finger.

Mit dieser Action könnt ihr die Ebenen-Einstellungen exportieren und importieren, ab Version 2.6.
Die Action ist leider nur in der API Doku enthalten, funktioniert aber wie gesagt im Scripting.

Danke an FrankS für den Hinweis in diesem Beitrag.

Action name = graphicallayertable

TYPE
Type of task to be performed by the action:
IMPORT: Import graphical layer table
EXPORT: Export graphical layer table

PROJECTNAME
Project name with full path (optional).
If not entered, the selected project is used when the action is called from GUI (like from a script or button bar). If called from the windows command line, PROJECTNAME must be set or the ProjectAction must be used first, otherwise an System.ArgumentException exception is thrown.

IMPORTFILE
The directory and the file name of the table to be imported must be specified here.

EXPORTFILE
The directory and the file name of the table to be exported must be specified here.

Import example:
graphicallayertable /TYPE:IMPORT /PROJECTNAME:C:\\Projects\\EPLAN\\EPLAN-DEMO.elk /IMPORTFILE:C:\\EPLAN\\EPLAN-DEMO.elc

Export example:
graphicallayertable /TYPE:EXPORT /PROJECTNAME:C:\\Projekte\\EPLAN\\EPLAN-DEMO.elk /EXPORTFILE:C:\\EPLAN\\EPLAN-DEMO.elc

 

Von |2017-11-09T11:22:13+01:002016-10-25|EPLAN, EPLAN-Scripts|

EPLAN-API: Showcase 2016 Oktober

Man merkt es hier bisl weniger, aber hab derzeit sehr viel mit der EPLAN API zu tun, was mir auch riesig Spaß macht.
Darum hier mal ein kleiner Auszug…

 

ToggleLayerTable

Viele von euch kennen bestimmt die API Erweiterung ToggleLayer. Mit der ist es möglich einzelne Ebenen umzuschalten. Aufgrund einer Kundenanforderung habe ich das ganze nun auch für die gesamte Ebenenverwaltung geschrieben. Der Action übergibt man einfach eine *.elc Datei, welche alle Ebenen beinhaltet und diese wird dann importiert.

Von |2016-10-20T07:36:57+02:002016-10-20|EPLAN, EPLAN-API|

EPLAN API: EPLAN Prozess in anderem Thread starten

Bei einer Offline Applikation hat man immer das Problem, man muss eine Oberfläche bereitstellen, welche immer reagiert und im besten Fall nicht einfriert.

Der EPLAN Prozess, braucht ziemlich lang zum hochfahren, darum will man den auch auslagern. Damit dieser aber in einem anderen Thread laufen kann ist folgender Code notwendig:

Thread newThread = new Thread(ThreadMethod);
newThread.SetApartmentState(ApartmentState.STA);
newThread.Start();

In der ThreadMethod()  kann dann EPLAN gestartet werden. Ich hatte es erst mit dem BackgroundWorker probiert, leider ist dieser MTA und somit nicht nutzbar.

Von |2016-10-11T13:39:53+02:002016-10-11|EPLAN, EPLAN-API|

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 |2016-10-05T18:00:45+02:002016-10-10|EPLAN, EPLAN-API, EPLAN-Bugs|

PlaceHolderMultiAddRecord

Frank hat ein schönes Script erstellt um mehrere Wertesätze schnell anzulegen.
Das Script wird über das Kontextmenü aufgerufen.

Download on GitHub

// PlaceHolderMultiAddRecord, Version 1.1.0, vom 04.11.2014
//
// Erweitert das Kontextmenü vom Platzhalterobjekt (Reiter Werte) um den Menüpunkt "Neuer Wertesatz (Mehrfach)..."
// Erlaubt darüber das anlegen von mehreren leeren Wertesätzen.
//
// Copyright by Frank Schöneck, 2013-2014
// letzte Änderung: Frank Schöneck, 16.01.2013 V1.0.0, Projektbeginn
//					Frank Schöneck, 04.11.2014 V1.1.0, Umgestellt von SendKeys auf Action "MacrosGuiIGfWindNewRecord"
//
// für Eplan Electric P8, ab V2.2
//

using System.Drawing;

public class FrankS_PlaceHolder
{
	[DeclareMenu()]
	public void PlaceHolderMultiAddRecordContextMenu()
	{
		//Context-Menüeintrag (hier im Platzhalterobjekt)
		Eplan.EplApi.Gui.ContextMenu oContextMenu = new Eplan.EplApi.Gui.ContextMenu();
		Eplan.EplApi.Gui.ContextMenuLocation oContextMenuLocation = new Eplan.EplApi.Gui.ContextMenuLocation("PlaceHolder", "1004");
		oContextMenu.AddMenuItem(oContextMenuLocation, "Neuer Wertesatz (&Mehrfach)...", "PlaceHolderMultiAddRecord", false, false);
	}

	[DeclareAction("PlaceHolderMultiAddRecord")]
	public void PlaceHolderMultiAddRecord_Action()
	{
		string value = "2";
		if (InputBox.Show("Neuer Wertesatz (Mehrfach)", "Wieviele Wertesätze sollen angelegt werden?", ref value) == DialogResult.OK)
		{
			int iValue = Convert.ToInt32(value); // Eingabe von Typ string in ein Typ int wandeln
			for (int i = 1; i <= iValue; i++)
			{
				new CommandLineInterpreter().Execute("MacrosGuiIGfWindNewRecord");
				//SendKeys.SendWait("^+{F10}W"); //Taste Kontextmenü aufrufen und direkt Taste W
			}
		}
		return;
	}
}

public class InputBox
{
	/// <summary>
	/// Displays a dialog with a prompt and textbox where the user can enter information
	/// </summary>
	/// <param name="title">Dialog title</param>
	/// <param name="promptText">Dialog prompt</param>
	/// <param name="value">Sets the initial value and returns the result</param>
	/// <returns>Dialog result</returns>
	public static DialogResult Show(string title, string promptText, ref string value)
	{
		Form form = new Form();
		Label label = new Label();
		TextBox textBox = new TextBox();
		Button buttonOk = new Button();
		Button buttonCancel = new Button();

		form.Text = title;
		label.Text = promptText;
		textBox.Text = value;

		buttonOk.Text = "OK";
		buttonCancel.Text = "Abbrechen";
		buttonOk.DialogResult = DialogResult.OK;
		buttonCancel.DialogResult = DialogResult.Cancel;

		label.SetBounds(9, 18, 372, 13);
		textBox.SetBounds(12, 36, 372, 20);
		buttonOk.SetBounds(228, 72, 75, 23);
		buttonCancel.SetBounds(309, 72, 75, 23);

		label.AutoSize = true;
		textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
		buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
		buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

		form.ClientSize = new Size(396, 107);
		form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
		form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
		form.FormBorderStyle = FormBorderStyle.FixedDialog;
		form.StartPosition = FormStartPosition.CenterScreen;
		form.MinimizeBox = false;
		form.MaximizeBox = false;
		form.AcceptButton = buttonOk;
		form.CancelButton = buttonCancel;

		DialogResult dialogResult = form.ShowDialog();
		value = textBox.Text;
		return dialogResult;
	}
}

 

Von |2018-08-17T12:30:23+02:002016-10-04|EPLAN, EPLAN-Scripts|
Nach oben