EPLAN-Scripts

Renumber

Aus der Reihe “wurde in der Doku vergessen”. Die Action Renumber ist nicht in der API und nicht in der Online-Hilfe.
Laut EPLAN ist es aber eine offizielle Action und wird in die Dokumentation mit aufgenommen. Anbei die Beschreibung der wohl mächtigsten Action in EPLAN. Es freut mich sehr dass diese Action es ins Scripting geschafft hat.

Action name = renumber

TYPE
Type of task to be performed by the action
DEVICES: Renumber devices.
PAGES: Renumber pages.
TERMINALS: Renumbering terminals
CABLES: Renumbering cables
ADDITIONALPAGEFIELDS: Renumbering additional page fileds
CONNECTIONS: Renumbering connections

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. This parameter is only effective with the following values of the TYPE
parameter:DEVICES, PAGES, TERMINALS, CABLES, ADDITIONALPAGEFIELDS,
CONNECTIONS.

USESELECTION
Optional. If this flag is set, only the objects currently selected in GUI will be renumbered
instead of all objects in the project. Possible values: '0' - No (default), '1' - Yes. This
parameter is only effective with the following values of the TYPE parameter:DEVICES,
PAGES, TERMINALS, CABLES, ADDITIONALPAGEFIELDS, CONNECTIONS.

CONFIGSCHEME
Name of the renumbering scheme. Optional. If not specified, the last used scheme will be
selected again. This parameter is only effective with the following values of the TYPE
parameter:DEVICES, TERMINALS, CABLES, CONNECTIONS.

STARTVALUE
Start value. Integer. Optional. If not specified, 1 is taken by default. This parameter is only
effective with the following values of the TYPE parameter:DEVICES, PAGES, TERMINALS,
CABLES, ADDITIONALPAGEFIELDS.
STEPVALUE Increment value. Integer. Optional. If not specified, 1 is taken by default. This parameter is
only effective with the following values of the TYPE parameter:DEVICES, PAGES, TERMINALS,
CABLES.

POSTNUMERATE
Optional. If this flag is set, only invalid device tags (i.e. those containing '?' character) will be
renumbered. Possible values: '0' - No (default), '1' - Yes. This parameter is only effective
with the following values of the TYPE parameter:DEVICES, TERMINALS.

ALSONUMERATEDBYPLC
Optional. If this flag is set, device tags which are influenced by PLC numbering will be
numerated. Possible values: '0' - No (default), '1' - Yes. This parameter is only effective with
the following values of the TYPE parameter:DEVICES, TERMINALS.

PERMITSORTCHANGE
Optional. Permit sort change. Possible values: '0' - No (default), '1' - Yes. This parameter is
only effective with the following values of the TYPE parameter:TERMINALS.

FILLGAPS
Optional. Fill Gaps. Possible values: '0' - No (default), '1' - Yes. This parameter is only
effective with the following values of the TYPE parameter:TERMINALS.
IDENTIFIER Identifier, e.g. 'X*'. Optional. If used, all devices from the project matching the identifier are
taken for renumeration regardless of whether the 'USESELECTION' parameter is used or not.
This parameter is only effective with the following values of the TYPE parameter:DEVICES.

NUMERATECABLES
Optional. If this flag is set, cables whose device tags contain source and target information
are also numerated. Possible values: '0' - No (default), '1' - Yes. This parameter is only
effective with the following values of the TYPE parameter:DEVICES.

STRUCTUREORIENTED
Set this parameter to true to provide numbering per structure identifier. If false, then pages
are continuously number without accounting for the structure identifiers. This parameter is
only effective with the following values of the TYPE parameter:PAGES.

KEEPINTERVAL
In combination with the definition of the start page, this parameter retains the increments
between the selected pages for the target pages. In this way you can move any desired
number of selected pages by a specified increment. Entering the increment size is not
possible in this case. This parameter is only effective with the following values of the TYPE
parameter:PAGES.

KEEPTEXT
Set this to 1, if the alphabetic part of the page name should not be overwritten. This
parameter is only effective with the following values of the TYPE parameter:PAGES.
SUBPAGES Values are:
• 0 = Retain: Existing subpages are adopted unchanged into the target page.
• 1 = ConsecutiveNumbering: Existing subpages are renumbered using the starting value "1"
and an increment of "1". At every change of the main page, the subpage numbering begins
again from "1". The subpage numbering follows the project settings defined in the project
setting "Characters for subpages".
• 2 = ConvertIntoMainPages: Subpages are converted to main pages and renumbered.
This parameter is only effective with the following values of the TYPE parameter:PAGES.

PREFIX
Prefix. This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.

SUFFIX
Suffix. This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.
SEQUENCE 
Mode to use for numbering. Values are:
• 0 = Like sorting: The terminal / pin sorting sequence displayed under Terminal strips -
(Project name) or Plugs - (Project name) is used. Select this option if you would like to
number existing terminals / pins but retain the existing sorting.
• 1 = Page oriented
• 2 = Cable oriented
• 3 = Level oriented
This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.

EXTENT
Parameter to define the scope of numbering. Values are:
• 0 = Selected - only the selected terminals or pins will be numbered.
• 1 = All selected terminal strips - all terminals of the same strip as selected terminal will be
numbered.
This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.

POTENTIAL_N
Parameter to determine how N terminals will be treated during numbering. Values are:
• 0 = Ignore
• 1 = Do not modify, include in sequence. PE, N or SH terminals are not modified during
numbering but are taken into account when numbering the other terminals. This means that
the designations of the other terminals are assigned as though the PE, N or SH terminals
were being included in the numbering.
• 2 = Renumber
This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.

POTENTIAL_PE
Parameter to determine how PE terminals will be treated during numbering. Values are:
• 0 = Ignore
• 1 = Do not modify, include in sequence. PE, N or SH terminals are not modified during
numbering but are taken into account when numbering the other terminals. This means that
the designations of the other terminals are assigned as though the PE, N or SH terminals
were being included in the numbering.
• 2 = Renumber
This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.

POTENTIAL_SH
Parameter to determine how SH terminals will be treated during numbering. Values are:
• 0 = Ignore
• 1 = Do not modify, include in sequence. PE, N or SH terminals are not modified during
numbering but are taken into account when numbering the other terminals. This means that
the designations of the other terminals are assigned as though the PE, N or SH terminals
were being included in the numbering.
• 2 = Renumber
This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.

MULTIPLETERMINALS
Also renumber multi path terminals.Values are:
• 0 = Dont modify - terminals with the property "Allow same designations" are ignored
during numbering
• 1 = Number same - terminals with the same designation with the "Allow same
designations" property are given the same number
• 2 = Number individually - terminals with the "Allow same designations" property are each
given their own number. Therefore, multiple terminals which had the same number before
numbering will have different numbers after numbering
This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.

KEEPALPHA
Keep alphabetical elements of the terminal number. Values are:
• 0 = Dont modify - terminals or pins with alphabetical elements in the designation are
ignored during numbering.
• 1 = Keep alphabetical elements - the alphabetical elements of the terminal or pin
designation are retained. The first numeric elements are renumbered. If the designation only
has alphabetical elements, the old designation is attached to the new numbering. Sequential
terminals with different counters but the same numerical component receive the same
numerical component in the counter even after the numbering.
• 2 = Number - all terminals / pins are renumbered. In doing so, the old designation is
overwritten
This parameter is only effective with the following values of the TYPE
parameter:TERMINALS.

KEEPEXISTING
Overwrite mode. If set to 1, already existing cable names will not be changed. This
parameter is only effective with the following values of the TYPE parameter:CABLES.
FIELD Additional page field(property number). This parameter is only effective with the following
values of the TYPE parameter:ADDITIONALPAGEFIELDS.
INDEX Additional page field property index. This parameter is only effective with the following
values of the TYPE parameter:ADDITIONALPAGEFIELDS.

NUMBERDIGITS
Number of digits from 0 to 10. This parameter is only effective with the following values of
the TYPE parameter:ADDITIONALPAGEFIELDS.

STARTVALUE_n
Start value. Where n is a connection group number (1,2,3...). This parameter is only
effective with the following values of the TYPE parameter:CONNECTIONS.

STEPVALUE_n
Step value. Where n is a connection group number (1,2,3...). This parameter is only effective
with the following values of the TYPE parameter:CONNECTIONS.
GROUP_n Group parameter. Where n is a connection group number (1,2,3...). This parameter is only
effective with the following values of the TYPE parameter:CONNECTIONS.
OVERWRITE Overwrite mode. Values are:
• 0 = All (always overwrite)
• 1 = ExceptManuals (overwrite all except those, which are marked as 'manually set')
• 2 = None (never overwrite)
This parameter is only effective with the following values of the TYPE
parameter:CONNECTIONS.

AVOIDIDENTICALDESIGNATIONS
Values are:
• 0 = In entire project
• 1 = In the selection
• 2 = None
• 3 = Per counter reset range (structure/page)
This parameter is only effective with the following values of the TYPE
parameter:CONNECTIONS.

VISIBILITY
Visiblity. Values are:
• 0 = All visible
• 1 = Do not modify
• 2 = Once per page and range
This parameter is only effective with the following values of the TYPE
parameter:CONNECTIONS.

MARKASMANUAL
Mark as 'manually set'. This parameter is only effective with the following values of the TYPE
parameter:CONNECTIONS. 

Example

Numbering devices
renumber /TYPE:DEVICES /STARTVALUE:1 /STEPVALUE:1 /USESELECTION:0 /OMITNUMERATEDBYPLC:0 /NUMERATECABLES:0 /IDENTIFIER:X* /CONFIGSCHEME:"Kennbuchstabe Zähler" /POSTNUMERATE:0
renumber /TYPE:DEVICES /IDENTIFIER:V /POSTNUMERATE:0 /ALSONUMERATEDBYPLC:1 /NUMERATECABLES:1 /STARTVALUE:100 /STEPVALUE:5 /USESELECTION:1

Numbering page supplementary fields
renumber /TYPE:ADDITIONALPAGEFIELDS /FIELD:11901 /INDEX:5 /STARTVALUE:13 /USESELECTION:1 /STEPVALUE:2 /NUMBERDIGITS:3 /USESELECTION:1

Numbering pages
renumber /TYPE:PAGES /STRUCTUREORIENTED:0 /STARTVALUE:3 /STEPVALUE:10 /KEEPINTERVAL:1 /KEEPTEXT:0 /SUBPAGES:1 /USESELECTION:0

Numbering cables
renumber /CONFIGSCHEME:Standard /TYPE:CABLES /STARTVALUE:7 /STEPVALUE:7 /USESELECTION:1 /KEEPEXISTING:1
renumber /TYPE:CABLES /STARTVALUE:999 /USESELECTION:0

Numbering connections
renumber /TYPE:CONNECTIONS /CONFIGSCHEME:Verbindungsorientiert /STARTVALUE_1:1 /STEPVALUE_1:1 /OVERWRITE:1 /AVOIDIDENTICALDESIGNATIONS:1 /VISIBILITY:1 /MARKASMANUAL:0 /USESELECTION:1 /GROUP_1:1
renumber /TYPE:CONNECTIONS /CONFIGSCHEME: Potenzialorientiert /STARTVALUE_1:13 /STEPVALUE_1:3 /OVERWRITE:0 /AVOIDIDENTICALDESIGNATIONS:0 /VISIBILITY:1 /MARKASMANUAL:1 /USESELECTION:0 /GROUP_1:1

Numbering terminals:
renumber /TYPE:TERMINALS /CONFIGSCHEME:Numerisch /SEQUENCE:1 /POTENTIAL_N:1 /POTENTIAL_PE:2 /POTENTIAL_SH:2 /POSTNUMERATE:0 /ALSONUMERATEDBYPLC:1 /MULTIPLETER
Von |2017-11-09T11:16:40+01:002016-10-27|EPLAN, EPLAN-Scripts|

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|

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|

Projekt ermitteln bei Event OnPostOpenProject

Ich habe in einem Script verschiedene Eventhandler die was im Projektordner (DOC) machen…
Klappt auch alles wunderbar… bis auf das Event vom Projekt öffnen. Ist mehr als ein Projekt geöffnet stimmt die Pfadvariable nicht:

var docFolder = PathMap.SubstitutePath("$(DOC)");

 

Durch den (immer tollen) EPLAN API Support habe ich folgende Lösung:

[DeclareEventHandler("Eplan.EplApi.OnPostOpenProject")] // project open
public void EventProjectOpen(IEventParameter iEventParameter)
{
   EventParameterString eventParameterString = new EventParameterString(iEventParameter);
   string projectFile = eventParameterString.String;

   FileInfo fileInfo = new FileInfo(projectFile);
   string projectDirectory = projectFile.Replace(fileInfo.Extension, ".edb");
   var docFolder = Path.Combine(projectDirectory, "DOC");
}
Von |2017-11-09T11:22:14+01:002016-07-27|EPLAN, EPLAN-Scripts|

Debugging mit DebugView

Ich hatte ja schon erklärt wie man Scripte schön Debuggen kann…
Zusätzlich nutze ich aber auch gerne DebugView um “schnell mal zu schauen”. Ist besser als mit Messageboxen zu arbeiten.

Einfach im Code z.B. schreiben:

Debug.WriteLine(logFile);

Und die Ausgabe sieht dann wie folgt aus:

DebugView

Es muss nichts eingestellt werden.

Von |2017-11-09T11:22:14+01:002016-07-26|EPLAN, EPLAN-Scripts|
Nach oben