Skript

Navigatoren einblenden / ausblenden

Dank dem API-Support der wie immer einfach nur toll ist, gibt es nun eine Möglichkeit Navigatoren ein- bzw. auszublenden.
Vielen Dank auch an FrankS der mir den Tip mit den Actions gegeben hat!

Ich hab das mal ausprogrammiert. Mit der Action kann man mehrere Navigatoren (oder einen) umschalten.

Update 2022-11-17
Ab EPLAN Version 2022 heißt der Einstellungsknoten anders:

string schemePath = "USER.WORKSPACE.NAMED";

wird zu:

string schemePath = "USER.WORKSPACE_BCG.NAMED";

Hab das im Script unten schon angepasst.

using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

namespace EplanScriptingProjectBySuplanus.ShowNavigators
{
    class ShowNavigators
    {
        [DeclareAction("ShowNavigators")]
        public bool Action(string actionNavigatorVisible)
        {
            // Objects
            var commandLineInterpreter = new CommandLineInterpreter();
            SchemeSetting schemeSetting = new SchemeSetting();
            Settings settings = new Settings();
            string schemePath = "USER.WORKSPACE.NAMED";
            string schemeName = "dummy";

            // SaveWorkspace
            commandLineInterpreter.Execute("SaveWorkspaceAction /Workspacename:dummy");

            // Parse parameter
            var splitGroups = actionNavigatorVisible.Split('|');
            foreach (var splitGroup in splitGroups)
            {
                // Get values
                var splitNavigators = splitGroup.Split(';');
                if (splitNavigators.Length != 2)
                {
                    MessageBox.Show("Invalid parameter", "ShowNavigators - Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return false;
                }

                string navigatorName = splitNavigators[0];
                string visibleText = splitNavigators[1].ToUpper();
                bool visible = visibleText == "TRUE" || visibleText == "1";

                // Settings path e.g.: USER.WORKSPACE_BCG.NAMED.dummy.Data.Visibility.XMacroPdd
                string settingsPath = schemePath + "." + schemeName + ".Data.Visibility." + navigatorName;

                // Hide & Seek :^)
                if (visible)
                {
                    // Show
                    if (!settings.ExistSetting(settingsPath))
                    {
                        commandLineInterpreter.Execute("GfDialogManagerShow /DialogName:" + navigatorName);
                    }
                }
                else
                {
                    // Hide
                    if (settings.ExistSetting(settingsPath))
                    {
                        commandLineInterpreter.Execute("GfDialogManagerHide /DialogName:" + navigatorName);
                    }
                }
            }

            // RemoveWorkspace            
            schemeSetting.Init(schemePath);
            if (schemeSetting.CheckIfSchemeExists(schemeName))
            {
                schemeSetting.RemoveScheme(schemeName);
            }
            

            return false;
        }
    }
}

 

Aufruf erfolgt mit (in diesem Beispiel wird der Seitennavigator sichtbar und der Betriebsmittelnavigator unsichtbar geschaltet):

ShowNavigators /actionNavigatorVisible:"PmPageIndexDialog;true|XNavigatorDlg;false"

Mehrere Navigatoren werden mit dem Pipe-Zeichen “|” getrennt. Pro Navigator muss Semikolon “;” getrennt folgendes angegeben werden:

  • Dialogname
  • Sichtbar (True: wird sichtbar geschaltet, False: wird unsichtbar geschaltet)

 

Die Daten bekommt Ihr wenn der Dialog eingeblendet wurde und Ihr STRG+^ drückt.

 

Download auf GitHub

Von |2022-11-17T10:07:10+01:002017-08-14|EPLAN, EPLAN-Scripts|

Toolbar per Script erzeugen

War mir bis jetzt auch nicht bekannt, aber dank des Beitrages von Franks jetzt schon :^)

// Create Toolbar
string toolbarName = "TEST_Toolbar";
Eplan.EplApi.Gui.Toolbar toolbar = new Eplan.EplApi.Gui.Toolbar();            
toolbar.CreateCustomToolbar(toolbarName, Eplan.EplApi.Gui.Toolbar.ToolBarDockPos.eToolbarFloat, 0, 0, true);

// Add buttons
toolbar.AddButton(toolbarName, 0, "strAction0", @"$(MD_IMG)\Toolbar\MountingPlateHandling\MP_0.jpg", "Tooltip0");
toolbar.AddButton(toolbarName, 1, 0); // Separator
toolbar.AddButton(toolbarName, 2, "strAction2", @"$(MD_IMG)\Toolbar\MountingPlateHandling\MP_90.jpg", "Tooltip2");
// Remove toolbar
toolbar.RemoveCustomToolbar(toolbarName);
Von |2017-11-09T11:16:27+01:002017-08-11|EPLAN, EPLAN-Scripts|

EPLAN 2.7: Scripting Neuerungen

Die Beta läuft ja schon ne Weile und ich hab mich mal hingesetzt und die neuen Action angeschaut. Folgende kamen dazu:

changeLayer
Ändert die grafischen Eigenschaften von Ebenen.
export3D
Exportiert Bauräume in das STEP-Format.
exportNCData
Exportiert NC-Daten
exportProductionWiring
Exportiert Drahtkonfektionierungsdaten in verschiedenen Formaten.
GraphicalLayerTable
Importiert / exportiert Ebenen.
Renumber
Führt eine Nummerierung durch.
XPlaUpdateDetailAction
Detailplanung wird aktualisiert
XPamSelectPart
Artikel aus GUI auswählen
Von |2017-11-09T11:16:27+01:002017-05-22|EPLAN, EPLAN-Scripts|

Multiuserkonflikt erkennen

Vorab: Leider geht das nur per API, nicht im Scripting.

Die Ermittlung der User ist schnell gemacht, hab aber noch einen Dialog dazu gepackt, welcher Infos über die User anzeigt:

public static bool IsMultiUserConflict(Project project, bool showDialog = false)
{
   var currentUsers = project.CurrentUsers.ToList();

   // No conflict
   if (currentUsers.Count <= 1)
   {
      return false;
   }

   // Conflict
   if (showDialog)
   {
      StringBuilder sb = new StringBuilder();
      foreach (var user in currentUsers)
      {
         if (!string.IsNullOrEmpty(user.Name) && !string.IsNullOrEmpty(user.Identification))
         {
            sb.AppendLine(user.ComputerName + " / " + user.Name + " / " + user.Identification);
         }
         else if (!string.IsNullOrEmpty(user.Name))
         {
            sb.AppendLine(user.ComputerName + " / " + user.Name);
         }
         else if (!string.IsNullOrEmpty(user.Identification))
         {
            sb.AppendLine(user.ComputerName + " / " + user.Identification);
         }
         else
         {
            sb.AppendLine(user.ComputerName);
         }
      }
      MessageBox.Show(sb.ToString(), "Multi user conflict", MessageBoxButton.OK, MessageBoxImage.Warning);
   }
   return true;
}
Von |2017-05-03T13:34:52+02:002017-05-04|EPLAN, EPLAN-API|
Nach oben