Archiv für das Jahr: 2016

RunSystemConfigurationDialog

Viele Leute haben in Foren oder Ähnliches schon nach einer Möglichkeit gefragt, wie man die EPLAN Stammdaten komplett umschalten kann.

Damit ist das Verzeichnis $(EPLAN_DATA) gemeint. Somit die Stammdaten.

EPLAN hat in der 2.6 eine Möglichkeit geschaffen, aber warum auch immer nicht dokumentiert. Somit wird es wohl auch (noch?!) nicht offiziell unterstützt.
Draufgekommen bin ich weil in der API-Hilfe etwas von den Befehlszeilenparameter dokumentiert war, da hab ich mal in den DLLs geschaut ob ne neue Action hinzukam.

Mit der versteckten Action RunSystemConfigurationDialog  kann man sich Schemata anlegen, welche dann per Aufrufparameter /SystemConfiguration  aufgerufen werden kann.

Wichtig ist dass er EPLAN mit Admin-Rechten startet, sonst könnt Ihr kein Schema anlegen.

Hier mal eine Bespielkonfiguration, welche ich für die API-Programmierung nutze und deren Aufruf:

"C:\Program Files\EPLAN\Platform\2.6.3\Bin\Eplan.exe" /Variant:"Electric P8" /SystemConfiguration:"API"
Von |2017-11-09T11:16:27+01:002016-12-14|EPLAN, EPLAN-Scripts|

EPLAN-API: Suchen & Ersetzen

Hört sich einfach an, ist aber bisl umständlich zu implementieren. Ich hab das mal ausprogrammiert… bin mir aber nicht sicher ob es alle Eigenschaften richtig setzt, bzw. ob es recht performant ist…

Verwendung

var project = ProjectUtility.GetCurrentProject();

Search search = new Search();
search[Search.Settings.AllProperties] = true;
search[Search.Settings.Placeholders] = true;
search[Search.Settings.DeviceTag] = true;
search[Search.Settings.GraphicPages] = true;
search[Search.Settings.InstallationSpaces] = true;
search[Search.Settings.LogicPages] = true;
search[Search.Settings.NotPlaced] = true;
search[Search.Settings.EvalutionPages] = false;
search[Search.Settings.PageData] = true;
search[Search.Settings.ProjectData] = true;
search[Search.Settings.Texts] = true;
search[Search.Settings.WholeTexts] = true;

search.ClearSearchDB(project); // important

const string SEARCH_TEXT = "MyStringToSearch";
const string REPLACE_TEXT = "MyNewString";

SearchUtility.SearchAndReplaceText(search, SEARCH_TEXT, REPLACE_TEXT, project);

 

Methode

/// <summary>
/// Find and replace text
/// </summary>
/// <param name="search">Searchobject with the given properties</param>
/// <param name="searchText">Text to search</param>
/// <param name="replaceText">Replacement text</param>
/// <param name="project">EPLAN Project</param>
public static void SearchAndReplaceText(Search search, string searchText, string replaceText, Project project)
{
   // Init search
   search.ClearSearchDB(project);
   search.Project(project, searchText);

   // Get objects
   StorableObject[] foundObjects = search.GetAllSearchDBEntries(project);
   foreach (var foundObject in foundObjects)
   {
      // Filter only text objects
      // todo: EPLAN fix (2.6) T1085938
      var existingValues = foundObject.Properties.ExistingValues
         .Where(p => !p.Definition.IsInternal &&
         (p.Definition.Type == PropertyDefinition.PropertyType.MultilangString ||
         p.Definition.Type == PropertyDefinition.PropertyType.String)).ToList();
      List<PropertyValue> existingValuesWithoutEmpty = new List<PropertyValue>();
      foreach (var propertyValue in existingValues)
      {
         if (propertyValue.Definition.IsIndexed)
         {
            foreach (int index in propertyValue.Indexes)
            {
               if (!propertyValue[index].IsEmpty)
               {
                  existingValuesWithoutEmpty.Add(propertyValue[index]);
               }
            }
         }
         else
         {
            if (!propertyValue.IsEmpty)
            {
               existingValuesWithoutEmpty.Add(propertyValue);
            }
         }
      }
      existingValues = existingValuesWithoutEmpty;

      // Replace
      foreach (PropertyValue propertyValue in existingValues)
      {
         switch (propertyValue.Definition.Type)
         {
            // MultiLanguageString
            case PropertyDefinition.PropertyType.MultilangString:
               MultiLangString multiLangString = propertyValue;
               var valueMultiLangString = multiLangString.GetAsString();
               if (valueMultiLangString.Contains(searchText))
               {
                  string newValue = valueMultiLangString.Replace(searchText, replaceText); // All languages
                  multiLangString.SetAsString(newValue);
                  propertyValue.Set(newValue);
               }
               break;

            // String
            case PropertyDefinition.PropertyType.String:
               var value = propertyValue.ToString();
               if (value.Contains(searchText))
               {
                  string newValue = value.Replace(searchText, replaceText);
                  propertyValue.Set(newValue);
               }
               break;
         }

      }
   }
}
Von |2016-12-13T07:55:09+01:002016-12-13|EPLAN, EPLAN-API|

XPrjActionProjectNew

Es gibt eine inoffizielle (somit nicht supportete) EPLAN Action zum Erstellen von Projekten: XPrjActionProjectNew

Action Name:
XPrjActionProjectNew

Parameter:
/SOURCE: Basisprojekt oder Projektvorlage
/TARTGET: Zieldatei (*.elk)
/QUIET: 0 oder 1 ob Dialoge unterdrückt werden sollen (z.B. Aktualisierung)

Die Einstellungen für Erstelldatum und Ersteller, müssen über diese Settings gesetzt werden:

USER.PrjManagementGUI.PrjNew.SetCreationDate 
USER.PrjManagementGUI.PrjNew.SetCreator
Von |2017-11-09T11:16:27+01:002016-11-18|EPLAN, 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|
Nach oben