public void OpenProjectAndSetPartsDbVoid(string PROJECT,string DATABASE) { if (File.Exists(DATABASE)) { Eplan.EplApi.Base.Settings oSettings = new Eplan.EplApi.Base.Settings(); oSettings.SetStringSetting("USER.PartsManagementGui.Database", DATABASE, 0); MessageBox.Show("Eingestellte Datenbank:\n" + DATABASE, "OpenProjectAndSetPartsDb", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Datenbank nicht gefunden:\n" + DATABASE + "\n\n Es wurde keine Änderung an den Einstellungen vorgenommen.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (File.Exists(PROJECT)) { ActionCallingContext accProjectOpen = new ActionCallingContext(); accProjectOpen.AddParameter("Project", PROJECT); new CommandLineInterpreter().Execute("ProjectOpen", accProjectOpen); } else { MessageBox.Show("Projekt nicht gefunden:\n" + PROJECT, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }
public void SetSortCodeAction() { //Use a Command Line Interpreter to call the Action CommandLineInterpreter CLI = new CommandLineInterpreter(); Eplan.EplApi.Base.Settings set = new Eplan.EplApi.Base.Settings(); if(!set.ExistSetting("USER.SCRIPTS.SORTCODE")) { bool bOk = set.AddNumericSetting("USER.SCRIPTS.SORTCODE", new int[] { 0 }, new Range[] { new Range { FromValue = 0, ToValue = 32768}}, "Sort code setting", new int[] { 0 }, ISettings.CreationFlag.Insert); } int index = set.GetNumericSetting("USER.SCRIPTS.SORTCODE", 0); ActionCallingContext ctx1 = new ActionCallingContext(); ctx1.AddParameter("propertyID","20809"); //Sort code ctx1.AddParameter("propertyIndex","0"); ctx1.AddParameter("propertyValue", index.ToString()); CLI.Execute("XEsSetPropertyAction", ctx1); set.SetNumericSetting("USER.SCRIPTS.SORTCODE", ++index, 0); return; }
public void PrintPagesVoid() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); string strPages = string.Empty; acc.AddParameter("TYPE", "PAGES"); oCLI.Execute("selectionset", acc); acc.GetParameter("PAGES", ref strPages); Progress oProgress = new Progress("SimpleProgress"); oProgress.SetAllowCancel(true); oProgress.SetAskOnCancel(true); oProgress.SetNeededSteps(3); oProgress.SetTitle("Drucken"); oProgress.ShowImmediately(); foreach (string Page in strPages.Split(';')) { if (!oProgress.Canceled()) { acc.AddParameter("PAGENAME", Page); oCLI.Execute("print", acc); } else { break; } } oProgress.EndPart(true); return; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); string strPages = string.Empty; acc.AddParameter("TYPE", "PAGES"); oCLI.Execute("selectionset", acc); acc.GetParameter("PAGES", ref strPages); string[] strPagesCount = strPages.Split(';'); int intPagesCount = strPagesCount.Length; string strProjectname = PathMap.SubstitutePath("$(PROJECTNAME)"); MessageBox.Show("Anzahl markierter Seiten:\n" + "►►► " + intPagesCount.ToString() + " ◄◄◄", "Markierte Seiten [" + strProjectname + "]", MessageBoxButtons.OK, MessageBoxIcon.Information); return; }
public void Function() { string strProjectpath = PathMap.SubstitutePath("$(PROJECTPATH)"); string strProjectname = PathMap.SubstitutePath("$(PROJECTNAME)"); string strFullProjectname = PathMap.SubstitutePath("$(P)"); string strDate = DateTime.Now.ToString("yyyy-MM-dd"); string strTime = DateTime.Now.ToString("hh-mm-ss"); string strBackupDirectory = strProjectpath + @"\Backup\"; string strBackupFilename = strProjectname + "_Backup_" + strDate + "_" + strTime; if (!System.IO.Directory.Exists(strBackupDirectory)) { System.IO.Directory.CreateDirectory(strBackupDirectory); } Progress oProgress = new Progress("SimpleProgress"); oProgress.SetAllowCancel(true); oProgress.SetAskOnCancel(true); oProgress.BeginPart(100, ""); oProgress.SetTitle("Backup"); oProgress.ShowImmediately(); if (!oProgress.Canceled()) { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("BACKUPMEDIA", "DISK"); acc.AddParameter("ARCHIVENAME", strBackupFilename); acc.AddParameter("BACKUPMETHOD", "BACKUP"); acc.AddParameter("COMPRESSPRJ", "1"); acc.AddParameter("INCLEXTDOCS", "1"); acc.AddParameter("BACKUPAMOUNT", "BACKUPAMOUNT_ALL"); acc.AddParameter("INCLIMAGES", "1"); acc.AddParameter("LogMsgActionDone", "true"); acc.AddParameter("DESTINATIONPATH", strBackupDirectory); acc.AddParameter("PROJECTNAME", strFullProjectname); acc.AddParameter("TYPE", "PROJECT"); oCLI.Execute("backup", acc); } oProgress.EndPart(true); MessageBox.Show( "Backup wurde erfolgreich erstellt:\n" + strBackupFilename, "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Information ); return; }
public void MultilanguageToolExamples_Settings_Void() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); oCLI.Execute("XTrSettingsDlgAction"); // Settings DEFAULT // Bei Eingabe übersetzen #region SetTranslationOnInput acc.AddParameter("ACTIVE", "YES"); // parameters: YES, NO oCLI.Execute("SetTranslationOnInput", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion // Groß- / Kleinschreibung beachten #region SetMatchCase acc.AddParameter("ACTIVE", "YES"); // parameters: YES, NO oCLI.Execute("SetMatchCase", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion // Bereits übersetzte Texte verändern #region SetChangeTranslatedText acc.AddParameter("ACTIVE", "YES"); // parameters: YES, NO oCLI.Execute("SetChangeTranslatedText", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion // Manuelle Auswahl bei Mehrfachbedeutungen #region SetManualSelectionForMultipleMeanings acc.AddParameter("ACTIVE", "YES"); // parameters: YES, NO oCLI.Execute("SetManualSelectionForMultipleMeanings", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion // Segment #region SetTranslationSegment acc.AddParameter("SEGMENT", "ENTIRE ENTRY"); // parameters: WORD, SENTENCE, ENTIRE ENTRY oCLI.Execute("SetTranslationSegment", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion // Groß- / Kleinschreibung #region SetUpperLowerCase acc.AddParameter("TYPE", "ALLUPPERCASE"); // parameters: ACCORDINGTODICTIONARY, ALLUPPERCASE, ALLLOWERCASE, CAPITALIZEFIRSTLETTER oCLI.Execute("SetUpperLowerCase", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion // Fehlende Übersetzung: Anzeigen #region SetShowMissingTranslation acc.AddParameter("ACTIVE", "YES"); // parameters: YES, NO oCLI.Execute("SetShowMissingTranslation", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion }
public void InsertPageMacroVoid() { string strFilename = @"C:\test.emp"; ActionCallingContext oAcc = new ActionCallingContext(); CommandLineInterpreter oCLI = new CommandLineInterpreter(); oAcc.AddParameter("filename", strFilename); oCLI.Execute("XMInsertPageMacro", oAcc); }
public void Function() { string strProjectpath = PathMap.SubstitutePath("$(PROJECTPATH)" + @"\"); Progress progress = new Progress("SimpleProgress"); progress.BeginPart(100, ""); progress.SetAllowCancel(true); if (!progress.Canceled()) { progress.BeginPart(50, "Artikelsummenstückliste wird erstellt..."); ActionCallingContext labellingContext = new ActionCallingContext(); labellingContext.AddParameter("CONFIGSCHEME", "Summarized parts list"); labellingContext.AddParameter("DESTINATIONFILE", strProjectpath + "Artikelsummenstückliste.xls"); labellingContext.AddParameter("FILTERSCHEME", ""); labellingContext.AddParameter("LANGUAGE", "de_DE"); labellingContext.AddParameter("LogMsgActionDone", "true"); labellingContext.AddParameter("SHOWOUTPUT", "1"); labellingContext.AddParameter("RECREPEAT", "1"); labellingContext.AddParameter("SORTSCHEME", ""); labellingContext.AddParameter("TASKREPEAT", "1"); new CommandLineInterpreter().Execute("label", labellingContext); progress.EndPart(); } if (!progress.Canceled()) { progress.BeginPart(50, "Betriebsmittelbeschriftung wird erstellt..."); ActionCallingContext labellingContext1 = new ActionCallingContext(); labellingContext1.AddParameter("CONFIGSCHEME", "Device tag list"); labellingContext1.AddParameter("DESTINATIONFILE", strProjectpath + "Betriebsmittelbeschriftung.xls"); labellingContext1.AddParameter("FILTERSCHEME", ""); labellingContext1.AddParameter("LANGUAGE", "de_DE"); labellingContext1.AddParameter("LogMsgActionDone", "true"); labellingContext1.AddParameter("SHOWOUTPUT", "1"); labellingContext1.AddParameter("RECREPEAT", "1"); labellingContext1.AddParameter("SORTSCHEME", ""); labellingContext1.AddParameter("TASKREPEAT", "1"); new CommandLineInterpreter().Execute("label", labellingContext1); progress.EndPart(); } progress.EndPart(true); return; }
public void Function(int SET) { try { string strScripts = PathMap.SubstitutePath("$(MD_SCRIPTS)" + @"\"); string strProject = PathMap.SubstitutePath("$(P)"); string strMessage = string.Empty; CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("Project", strProject); switch (SET) { case 1: strMessage = "[Wie gezeichnet]"; acc.AddParameter("XMLFile", strScripts + @"1.xml"); break; case 2: strMessage = "[Als Punkt]"; acc.AddParameter("XMLFile", strScripts + @"2.xml"); break; case 3: strMessage = "[Mit Zielfestlegung]"; acc.AddParameter("XMLFile", strScripts + @"3.xml"); break; default: MessageBox.Show("Parameter nicht bekannt", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } oCLI.Execute("XSettingsImport", acc); MessageBox.Show("Einstellungen wurden importiert.\n" + strMessage, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("ScriptFile", @"C:\EPLAN Scripting Project\01_Erste_Schritte\01_Start.cs"); oCLI.Execute("ExecuteScript", acc); return; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("Name", "XGedIaFormatText"); acc.AddParameter("height", "20"); oCLI.Execute("XGedStartInteractionAction", acc); return; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("TYPE", "DXFPAGE"); acc.AddParameter("IMPORTFILE", @"C:\DXF\Smile.dxf"); oCLI.Execute("import", acc); return; }
/// <summary> /// Execution of the Action. /// </summary> /// <returns>True: Execution of the Action was successful</returns> public bool Execute(ActionCallingContext ctx) { SelectionSet sel = new SelectionSet(); List<Line> lines = sel.Selection.OfType<Line>().ToList(); foreach (Line l in lines) { l.EndArrow = !l.EndArrow; } return true; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("TYPE", "PROJECT"); oCLI.Execute("print", acc); MessageBox.Show("Action ausgeführt."); return; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("PAGENAME", "=+/1"); acc.AddParameter("DEVICENAME", "=+-1K1"); acc.AddParameter("FORMAT", "XDLTxtImporterExporter"); oCLI.Execute("edit", acc); return; }
public void Execute() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); string ActionReturnParameterValue = string.Empty; acc.AddParameter("Language", "Project"); // parameters: "Project" or "Display" acc.AddParameter("DialogName", "MyDialogName"); oCLI.Execute("SelectLanguage", acc); acc.GetParameter("Language", ref ActionReturnParameterValue); MessageBox.Show("Language from SelectLanguage:\n\n---> " + ActionReturnParameterValue); }
public void Function() { string strProjectname = PathMap.SubstitutePath("$(PROJECTNAME)"); string strFullProjectname = PathMap.SubstitutePath("$(P)"); string strDestination = strFullProjectname; DialogResult Result = MessageBox.Show( "Soll eine Sicherung für das Projekt\n'" + strProjectname + "'\nerzeugt werden?", "Datensicherung", MessageBoxButtons.YesNo, MessageBoxIcon.Question ); if (Result == DialogResult.Yes) { string myTime = System.DateTime.Now.ToString("yyyy.MM.dd"); string hour = System.DateTime.Now.Hour.ToString(); string minute = System.DateTime.Now.Minute.ToString(); Progress progress = new Progress("SimpleProgress"); progress.BeginPart(100, ""); progress.SetAllowCancel(true); if (!progress.Canceled()) { progress.BeginPart(33, "Backup"); ActionCallingContext backupContext = new ActionCallingContext(); backupContext.AddParameter("BACKUPMEDIA", "DISK"); backupContext.AddParameter("BACKUPMETHOD", "BACKUP"); backupContext.AddParameter("COMPRESSPRJ", "0"); backupContext.AddParameter("INCLEXTDOCS", "1"); backupContext.AddParameter("BACKUPAMOUNT", "BACKUPAMOUNT_ALL"); backupContext.AddParameter("INCLIMAGES", "1"); backupContext.AddParameter("LogMsgActionDone", "true"); backupContext.AddParameter("DESTINATIONPATH", strDestination); backupContext.AddParameter("PROJECTNAME", strFullProjectname); backupContext.AddParameter("TYPE", "PROJECT"); backupContext.AddParameter("ARCHIVENAME", strProjectname + "_" + myTime + "_" + hour + "." + minute + "."); new CommandLineInterpreter().Execute("backup", backupContext); progress.EndPart(); } progress.EndPart(true); } return; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("CONFIGSCHEME", "Standard"); acc.AddParameter("FILTERSCHEME", "Allpolig"); oCLI.Execute("compress", acc); MessageBox.Show("Action ausgeführt."); return; }
public void PagePdfVoid() { FolderBrowserDialog fbd = new FolderBrowserDialog(); CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); if (fbd.ShowDialog() != DialogResult.OK) { return; } Progress oProgress = new Progress("SimpleProgress"); oProgress.SetAllowCancel(true); oProgress.SetAskOnCancel(true); oProgress.BeginPart(100, ""); oProgress.ShowImmediately(); try { string strPages = string.Empty; acc.AddParameter("TYPE", "PAGES"); oCLI.Execute("selectionset", acc); acc.GetParameter("PAGES", ref strPages); foreach (string CurrentPage in strPages.Split(';')) { if (!oProgress.Canceled()) { acc.AddParameter("TYPE", "PDFPAGESSCHEME"); acc.AddParameter("PAGENAME", CurrentPage); acc.AddParameter("EXPORTFILE", fbd.SelectedPath + @"\" + CurrentPage); acc.AddParameter("EXPORTSCHEME", "EPLAN_default_value"); oCLI.Execute("export", acc); } else { oProgress.EndPart(true); return; } } Process.Start(fbd.SelectedPath); oProgress.EndPart(true); } catch (System.Exception ex) { oProgress.EndPart(true); MessageBox.Show("Error", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("PropertyId", "10013"); acc.AddParameter("PropertyIndex", "0"); acc.AddParameter("PropertyValue", "23542"); oCLI.Execute("XEsSetProjectPropertyAction", acc); MessageBox.Show("Action ausgeführt."); return; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("Project", @"C:\Projekte\Beispielprojekt.elk"); acc.AddParameter("Action", "reports"); acc.AddParameter("NOCLOSE", "1"); oCLI.Execute("ProjectAction", acc); MessageBox.Show("Action ausgeführt."); return; }
/// <summary> /// Execution of the Action. /// </summary> /// <returns>True: Execution of the Action was successful</returns> public bool Execute(ActionCallingContext ctx) { using (UndoStep undo = new UndoManager().CreateUndoStep()) { SelectionSet sel = new SelectionSet(); //Make sure that terminals are ordered by designation var terminals = sel.Selection.OfType<Terminal>().OrderBy(t => t.Properties.FUNC_PINORTERMINALNUMBER.ToInt()); if (terminals.Count() < 2) throw new Exception("Must select at least 2 Terminals"); //Create a list of terminals for each level. Those lists get added to a dictionnary //with the level as the key. Dictionary<int, List<Terminal>> levels = new Dictionary<int, List<Terminal>>(); //Fill the dictionnary foreach (Terminal t in terminals) { int level = t.Properties.FUNC_TERMINALLEVEL; if (!levels.ContainsKey(level)) levels.Add(level, new List<Terminal>()); levels[level].Add(t); } var keys = levels.Keys.OrderBy(k => k); //Make sure that all levels have the same number of terminals int qty = levels.First().Value.Count; if (!levels.All(l => l.Value.Count == qty)) throw new Exception("There must be the same number of Terminals on each level"); //Assign sort code by taking a terminal from each level in sequence int sortCode = 1; for (int i = 0; i < qty; i++) { foreach (int j in keys) { levels[j][i].Properties.FUNC_TERMINALSORTCODE = sortCode++; } } } return true; }
public void Function() { string strFilename = string.Empty; strFilename = CheckFilename("Artikelsummenstückliste.xls"); if (strFilename != "") { ActionCallingContext labellingContext = new ActionCallingContext(); labellingContext.AddParameter("CONFIGSCHEME", "Summarized parts list"); labellingContext.AddParameter("DESTINATIONFILE", strFilename); labellingContext.AddParameter("FILTERSCHEME", ""); labellingContext.AddParameter("LANGUAGE", "de_DE"); labellingContext.AddParameter("LogMsgActionDone", "true"); labellingContext.AddParameter("SHOWOUTPUT", "1"); labellingContext.AddParameter("RECREPEAT", "1"); labellingContext.AddParameter("SORTSCHEME", ""); labellingContext.AddParameter("TASKREPEAT", "1"); new CommandLineInterpreter().Execute("label", labellingContext); } strFilename = CheckFilename("Betriebsmittelbeschriftung.xls"); if (strFilename != "") { ActionCallingContext labellingContext1 = new ActionCallingContext(); labellingContext1.AddParameter("CONFIGSCHEME", "Device tag list"); labellingContext1.AddParameter("DESTINATIONFILE", strFilename); labellingContext1.AddParameter("FILTERSCHEME", ""); labellingContext1.AddParameter("LANGUAGE", "de_DE"); labellingContext1.AddParameter("LogMsgActionDone", "true"); labellingContext1.AddParameter("SHOWOUTPUT", "1"); labellingContext1.AddParameter("RECREPEAT", "1"); labellingContext1.AddParameter("SORTSCHEME", ""); labellingContext1.AddParameter("TASKREPEAT", "1"); new CommandLineInterpreter().Execute("label", labellingContext1); } return; }
private static void LabellingText(string filename) { ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("CONFIGSCHEME", "Zuletzt verwendete EPLAN-Version_Textdatei"); acc.AddParameter("DESTINATIONFILE", filename); acc.AddParameter("FILTERSCHEME", ""); acc.AddParameter("LANGUAGE", "de_DE"); acc.AddParameter("LogMsgActionDone", "true"); acc.AddParameter("SHOWOUTPUT", "0"); acc.AddParameter("RECREPEAT", "1"); acc.AddParameter("SORTSCHEME", ""); acc.AddParameter("TASKREPEAT", "1"); new CommandLineInterpreter().Execute("label", acc); return; }
public void Function() { string strProjectpath = PathMap.SubstitutePath("$(PROJECTPATH)") + @"\"; CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("TYPE", "EXPORT"); acc.AddParameter("EXPORTFILE", strProjectpath + "Partlist.txt"); acc.AddParameter("FORMAT", "XPalCSVConverter"); oCLI.Execute("partslist", acc); MessageBox.Show("Action ausgeführt."); return; }
public void MultilanguageToolExamples_Get_Void() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); string ActionReturnParameterValue = string.Empty; string strMessage = string.Empty; #region GetProjectLanguages oCLI.Execute("GetProjectLanguages", acc); acc.GetParameter("LANGUAGELIST", ref ActionReturnParameterValue); string[] ProjectLanguages = ActionReturnParameterValue.Split(';'); foreach (string s in ProjectLanguages) { strMessage = strMessage + s + "\n"; } MessageBox.Show(strMessage, "GetProjectLanguages"); strMessage = string.Empty; #endregion #region GetDisplayLanguages oCLI.Execute("GetDisplayLanguages", acc); acc.GetParameter("LANGUAGELIST", ref ActionReturnParameterValue); string[] DisplayLanguages = ActionReturnParameterValue.Split(';'); foreach(string s in DisplayLanguages) { strMessage = strMessage + s + "\n"; } MessageBox.Show(strMessage, "GetDisplayLanguages"); strMessage = string.Empty; #endregion #region GetVariableLanguage oCLI.Execute("GetVariableLanguage", acc); acc.GetParameter("LANGUAGELIST", ref ActionReturnParameterValue); string VariableLanguage = ActionReturnParameterValue; strMessage = strMessage + VariableLanguage + "\n"; MessageBox.Show(strMessage, "GetVariableLanguage"); strMessage = string.Empty; #endregion }
public void Function() { string strFullProjectname = PathMap.SubstitutePath("$(P)"); string strProjectpath = PathMap.SubstitutePath("$(PROJECTPATH)" + @"\"); string strProjectname = PathMap.SubstitutePath("$(PROJECTNAME)"); DialogResult Result = MessageBox.Show( "Soll ein PDF für das Projekt\n'" + strProjectname + "'\nerzeugt werden?", "PDF-Export", MessageBoxButtons.YesNo, MessageBoxIcon.Question ); if (Result == DialogResult.Yes) { Progress oProgress = new Progress("SimpleProgress"); oProgress.SetAllowCancel(true); oProgress.SetAskOnCancel(true); oProgress.BeginPart(100, ""); oProgress.ShowImmediately(); CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("TYPE", "PDFPROJECTSCHEME"); acc.AddParameter("PROJECTNAME", strFullProjectname); acc.AddParameter("EXPORTFILE", strProjectpath + strProjectname); acc.AddParameter("EXPORTSCHEME", "EPLAN_default_value"); oCLI.Execute("export", acc); oProgress.EndPart(true); } return; }
public void MultilanguageToolExamples_Set_Void() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); oCLI.Execute("XTrSettingsDlgAction"); // Settings DEFAULT #region SetProjectLanguages acc.AddParameter("LANGUAGELIST", "de_DE;en_EN;zh_CN;"); oCLI.Execute("SetProjectLanguages", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion #region ChangeLanguage acc.AddParameter("varLANGUAGE","en_EN"); acc.AddParameter("dispLANGUAGE", "en_EN;zh_CN;"); oCLI.Execute("ChangeLanguage", acc); oCLI.Execute("XTrSettingsDlgAction"); #endregion }
public void ActionFunction() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); string strPages = string.Empty; acc.AddParameter("TYPE", "PAGES"); oCLI.Execute("selectionset", acc); acc.GetParameter("PAGES", ref strPages); acc.AddParameter("PAGENAME", strPages); oCLI.Execute("print", acc); //MessageBox.Show("Seite gedruckt"); return; }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("TYPE", "PROJECT"); acc.AddParameter("ARCHIVENAME", @"C:\Projekte\Beispielprojekt.zw1"); acc.AddParameter("PROJECTNAME", @"C:\Projekte\Beispielprojekt.elk"); acc.AddParameter("UNPACKPROJECT", "0"); acc.AddParameter("MODE", "1"); acc.AddParameter("NOCLOSE", "1"); oCLI.Execute("restore", acc); MessageBox.Show("Action ausgeführt."); return; }
public void PrintPagesVoid() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); string strPages = string.Empty; acc.AddParameter("TYPE", "PAGES"); oCLI.Execute("selectionset", acc); acc.GetParameter("PAGES", ref strPages); Progress oProgress = new Progress("SimpleProgress"); oProgress.SetAllowCancel(true); oProgress.SetAskOnCancel(true); oProgress.SetNeededSteps(3); oProgress.SetTitle("Drucken"); oProgress.ShowImmediately(); foreach (string Page in strPages.Split(';')) { if (!oProgress.Canceled()) { acc.AddParameter("PAGENAME", Page); oCLI.Execute("print", acc); } else { break; } } oProgress.EndPart(true); return; }
public bool MyMacroBoxName(string EXTENSION, string GETNAMEFROMLEVEL) { //parameter description: //---------------------- //EXTENSION ... macroname extionsion (e.g. '.ems') //GETNAMEFROMLEVEL ... get macro name form level code (e.g. 1 = Funktionale Zuordnung, 2 = Anlage, 3 = Aufstellungsort, 4 = Einbauort, 5 = Dokumentenart, 6 = Benutzerdefiniert, P = Seitenname) try { string sPages = string.Empty; ActionCallingContext oCTX1 = new ActionCallingContext(); CommandLineInterpreter oCLI1 = new CommandLineInterpreter(); oCTX1.AddParameter("TYPE", "PAGES"); oCLI1.Execute("selectionset", oCTX1); oCTX1.GetParameter("PAGES", ref sPages); string[] sarrPages = sPages.Split(';'); if (sarrPages.Length > 1) { MessageBox.Show("Mehr als eine Seite markiert.\nAktion nicht möglich...", "Hinweis..."); return(false); } #region get macroname string sPageName = sarrPages[0]; //ensure unique level codes: //Funktionale Zuordnung -> $ //Aufstellungsort -> % sPageName = sPageName.Replace("==", "$").Replace("++", "%"); //get location from pagename string sMacroBoxName = string.Empty; //add needed / wanted structures to macroname #region generate macroname string[] sNeededLevels = GETNAMEFROMLEVEL.Split('|'); foreach (string sLevel in sNeededLevels) { switch (sLevel) { case "1": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName += ExtractLevelName(sPageName, "$"); } else { sMacroBoxName += "\\" + ExtractLevelName(sPageName, "$"); } break; case "2": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName += ExtractLevelName(sPageName, "="); } else { sMacroBoxName += "\\" + ExtractLevelName(sPageName, "="); } break; case "3": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "%"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "%"); } break; case "4": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "+"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "+"); } break; case "5": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "&"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "&"); } break; case "6": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "#"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "#"); } break; case "P": //Seitenname if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "/"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "/"); } break; default: break; } } #endregion //Clean-up macroname if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName.Remove(sMacroBoxName.Length - 1, 1); } if (sMacroBoxName.StartsWith(@"\")) { sMacroBoxName = sMacroBoxName.Substring(1); } if (sMacroBoxName == string.Empty) { MessageBox.Show("Es konnte kein Makroname ermittelt werden...", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } sMacroBoxName = sMacroBoxName.Replace(".", @"\") + EXTENSION; #endregion //set macrobox: macroname string quote = "\""; CommandLineInterpreter oCLI2 = new CommandLineInterpreter(); oCLI2.Execute("XEsSetPropertyAction /PropertyId:23001 /PropertyIndex:0 /PropertyValue:" + quote + sMacroBoxName + quote); return(true); } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
//Start Button private void ButtonOk_Click(object sender, System.EventArgs e) { Cursor.Current = Cursors.WaitCursor; while (!string.IsNullOrEmpty(PathMap.SubstitutePath("$(PROJECTNAME)"))) { LabelProject.Text = "Projekt in Bearbeitung: " + PathMap.SubstitutePath("$(PROJECTNAME)"); LabelProject.Refresh(); // this.PrueflaufCheck.Visible = false; this.AuswertenCheck.Visible = false; this.sichernCheck.Visible = false; this.PdfCheck.Visible = false; // ActionCallingContext ProjektContext = new ActionCallingContext(); ProjektContext.AddParameter("NOCLOSE", "0"); CommandLineInterpreter cli = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); //string projectName = PathMap.SubstitutePath("$(PROJECTNAME)"); proj.Add(PathMap.SubstitutePath("$(PROJECTNAME)")); if (CheckBoxProjectCheck.Checked) { this.PrueflaufCheck.Visible = true; this.PrueflaufCheck.Text = "...in Bearbeitung"; this.PrueflaufCheck.Refresh(); acc.AddParameter("TYPE", "PROJECT"); cli.Execute("check", acc); this.PrueflaufCheck.Text = "✓"; this.PrueflaufCheck.Refresh(); } if (CheckBoxReport.Checked) { this.AuswertenCheck.Visible = true; this.AuswertenCheck.Text = "...in Bearbeitung"; this.AuswertenCheck.Refresh(); cli.Execute("reports"); this.AuswertenCheck.Text = "✓"; this.AuswertenCheck.Refresh(); } if (CheckBoxBackup.Checked) { this.sichernCheck.Visible = true; this.sichernCheck.Text = "...in Bearbeitung"; this.sichernCheck.Refresh(); string projectName = PathMap.SubstitutePath("$(PROJECTNAME)"); string date = DateTime.Now.ToString("yyyy.MM.dd"); string backupFileName = projectName + "_" + date + ".zw1"; string backupPath = this.TextBoxLocationPath.Text; string pattern = @"[^\\]*[0-9-A-Z-a-z]_([^;]*)zw1"; // [^\\]*[0-9-A-Z-a-z]_([^;]*)zw1 // [^\\]*[\w]_([^;]*)zw1 string pathZW = Regex.Replace(backupPath, pattern, ""); acc.AddParameter("BACKUPAMOUNT", "BACKUPAMOUNT_ALL"); acc.AddParameter("BACKUPMEDIA", "DISK"); acc.AddParameter("BACKUPMETHOD", "BACKUP"); acc.AddParameter("COMPRESSPRJ", "1"); acc.AddParameter("INCLEXTDOCS", "1"); acc.AddParameter("INCLIMAGES", "1"); acc.AddParameter("ARCHIVENAME", backupFileName); acc.AddParameter("DESTINATIONPATH", pathZW); acc.AddParameter("TYPE", "PROJECT"); cli.Execute("backup", acc); this.sichernCheck.Text = "✓"; this.sichernCheck.Refresh(); } if (CheckBoxExportPDF.Checked) { this.PdfCheck.Visible = true; this.PdfCheck.Text = "...in Bearbeitung"; this.PdfCheck.Refresh(); string projectName = PathMap.SubstitutePath("$(PROJECTNAME)"); string date = DateTime.Now.ToString("yyyy.MM.dd"); string backupFileNamePDF = projectName + "_" + date + ".pdf"; string backupPath = this.TextBoxLocationPath.Text; string pattern = @"[^\\]*[0-9-A-Z-a-z]_([^;]*)zw1"; // [^\\]*[0-9-A-Z-a-z]_([^;]*)zw1 // [^\\]*[\w]_([^;]*)zw1 string pathZW = Regex.Replace(backupPath, pattern, ""); string backupFullFileNamePDF = Path.Combine(pathZW, backupFileNamePDF); //MessageBox.Show(backupFullFileNamePDF); acc.AddParameter("TYPE", "PDFPROJECTSCHEME"); if (radioButton2.Checked) { this.radioButton1.Checked = false; acc.AddParameter("BLACKWHITE", "1"); } else if (radioButton1.Checked) { acc.AddParameter("BLACKWHITE", "0"); this.radioButton2.Checked = false; } else { acc.AddParameter("BLACKWHITE", "0"); } acc.AddParameter("EXPORTFILE", backupFullFileNamePDF); acc.AddParameter("EXPORTSCHEME", "EPLAN_default_value"); cli.Execute("export", acc); this.PdfCheck.Text = "✓"; this.PdfCheck.Refresh(); } new CommandLineInterpreter().Execute("XPrjActionProjectClose", ProjektContext); } Cursor.Current = Cursors.Default; foreach (string x in proj) { allProj += x + Environment.NewLine; } MessageBox.Show( "Ausgabe für: " + Environment.NewLine + allProj + "wurde erledigt." , "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Information ); this.Close(); return; }
/// <summary> /// Execute Action /// </summary> /// <param name="oActionCallingContext"></param> /// <returns></returns> public bool Execute(ActionCallingContext oActionCallingContext) { SelectionSet Set = new SelectionSet(); Project CurrentProject = Set.GetCurrentProject(true); string ProjectName = CurrentProject.ProjectName; Debug.WriteLine(ProjectName); string xlsFileName = Path.GetDirectoryName(CurrentProject.ProjectFullName); xlsFileName = Path.Combine(xlsFileName, $"{ DateTime.Now.Year }.{ DateTime.Now.Month }.{ DateTime.Now.Day }_" + Settings.Default.outputFileName); // Show ProgressBar Progress progress = new Progress("SimpleProgress"); progress.SetAllowCancel(true); progress.SetAskOnCancel(true); progress.SetTitle("Wire mark export"); progress.ShowImmediately(); progress.BeginPart(25.0, "Export label : "); try { // Executing Action "label" ExportXML.Execute(xmlExportFileName); if (progress.Canceled()) { progress.EndPart(true); return(true); } } catch (Exception ex) { ErrorHandler("ExportXML", ex); return(false); } progress.EndPart(); progress.BeginPart(25.0, "Parse XML : "); try { // Getting object from XML ParseXMLWireFile(); if (progress.Canceled()) { progress.EndPart(true); return(true); } } catch (Exception ex) { ErrorHandler("ParseXMLWireFile", ex); return(false); } progress.EndPart(); progress.BeginPart(10.0, "Write data to Excel : " + xlsFileName); try { // Export to excel // Creating *.xls file ExportToExcel.Execute(listOfLines, xlsFileName, progress); if (progress.Canceled()) { progress.EndPart(true); return(true); } } catch (Exception ex) { ErrorHandler("ExportToExcel.Execute", ex); return(false); } finally { progress.EndPart(true); } return(true); }
/// <summary> /// Execution of the Action. /// </summary> /// <returns>True: Execution of the Action was successful</returns> public bool Execute(ActionCallingContext ctx) { new ApiExtSampleForm().ShowDialog(); return(true); }
private void OnPostOpenProject(IEventParameter iEventParameter) { //Если нет активного проекта, считываем описание и работаем с ним. if (EProjectManager.GetInstance().GetCurrentPrj() == null) { //Получение текущего проекта. Eplan.EplApi.HEServices.SelectionSet selection = new Eplan.EplApi.HEServices.SelectionSet(); selection.LockSelectionByDefault = false; selection.LockProjectByDefault = false; EProjectManager.GetInstance().SetCurrentPrj( selection.GetCurrentProject(true)); String strAction = "LoadDescriptionAction"; ActionManager oAMnr = new ActionManager(); Eplan.EplApi.ApplicationFramework.Action oAction = oAMnr.FindAction(strAction); ActionCallingContext ctx = new ActionCallingContext(); if (oAction != null) { oAction.Execute(ctx); } strAction = "ShowTechObjectsAction"; oAction = oAMnr.FindAction(strAction); if (oAction != null) { //Восстановление при необходимости окна редактора. string path = Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData) + @"\Eplan\eplan.cfg"; PInvoke.IniFile ini = new PInvoke.IniFile(path); string res = ini.ReadString("main", "show_obj_window", "false"); if (res == "true") { oAction.Execute(ctx); } } strAction = "ShowDevicesAction"; oAction = oAMnr.FindAction(strAction); if (oAction != null) { //Восстановление при необходимости окна устройств. string path = Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData) + @"\Eplan\eplan.cfg"; PInvoke.IniFile ini = new PInvoke.IniFile(path); string res = ini.ReadString("main", "show_dev_window", "false"); if (res == "true") { oAction.Execute(ctx); } } strAction = "ShowOperationsAction"; oAction = oAMnr.FindAction(strAction); if (oAction != null) { //Восстановление при необходимости окна операций. string path = Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData) + @"\Eplan\eplan.cfg"; PInvoke.IniFile ini = new PInvoke.IniFile(path); string res = ini.ReadString("main", "show_oper_window", "false"); if (res == "true") { oAction.Execute(ctx); } } // Проект открыт, ставим флаг в изначальное состояние. EProjectManager.isPreCloseProjectComplete = false; } }
public bool Execute(ActionCallingContext actionCallingContext) { // Sent events to WPF control from base action string itemType = string.Empty; string action = string.Empty; string key = string.Empty; actionCallingContext.GetParameter("itemtype", ref itemType); actionCallingContext.GetParameter("action", ref action); actionCallingContext.GetParameter("key", ref key); // Check specific itemType if (itemType != ItemType) { return(true); } WPFDialogEventManager wpfDialogEventManager = new WPFDialogEventManager(); switch (action) { case "SelectItem": wpfDialogEventManager.send("XPartsManagementDialog", action, key); break; case "SaveItem": wpfDialogEventManager.send("XPartsManagementDialog", "SaveItem", key); break; case "GetRootLevel": Data.Load(); actionCallingContext.AddParameter("text", ItemType); actionCallingContext.AddParameter("key", "0"); break; case "GetNextLevel": string keys = string.Empty; string texts = string.Empty; foreach (var itemTypeObject in Data.ItemTypeObjects.OrderBy(obj => obj.Text)) { if (keys != string.Empty) { keys += "\n"; } if (texts != string.Empty) { texts += "\n"; } keys += itemTypeObject.Key; texts += itemTypeObject.Text; } actionCallingContext.AddParameter("key", keys); actionCallingContext.AddParameter("text", texts); break; case "PreShowTab": if (string.IsNullOrEmpty(key) || key == "0") // Dont show on root level { actionCallingContext.AddParameter("show", "0"); } else { actionCallingContext.AddParameter("show", "1"); } break; case "DeleteItem": ItemTypeObject itemTypObjectToRemove = Data.ItemTypeObjects.First(obj => obj.Key.Equals(key)); Data.ItemTypeObjects.Remove(itemTypObjectToRemove); Data.Save(); break; case "CopyItem": string newKeyCopy = Guid.NewGuid().ToString(); string sourceKey = string.Empty; actionCallingContext.GetParameter("sourcekey", ref sourceKey); ItemTypeObject sourceItemTypeObject = Data.ItemTypeObjects.First(obj => obj.Key.Equals(sourceKey)); ItemTypeObject newItemTypeObjectCopy = new ItemTypeObject() { Key = newKeyCopy, Text = sourceItemTypeObject.Text, }; Data.ItemTypeObjects.Add(newItemTypeObjectCopy); key = newKeyCopy; actionCallingContext.AddParameter("key", key); Data.Save(); break; case "NewItem": string newKey = Guid.NewGuid().ToString(); ItemTypeObject newItemTypeObject = new ItemTypeObject() { Key = newKey, Text = "New item" }; Data.ItemTypeObjects.Add(newItemTypeObject); key = newKey; actionCallingContext.AddParameter("key", key); Data.Save(); break; } return(true); }
public bool Execute(ActionCallingContext ctx) { MessageBox.Show("ActionApiExtSimple was called!"); return(true); }
public void PDFPerLocationAction(string rootFolder) { /* This script loads the following scheme files from the $(MD_SCHEME) folder: * * LB.Mounting_Location_List.xml : Labeling scheme to export project's Sturecture Identifiers. * Relies on the FGfiSO.Mounting_Locations_only.xml labeling filter * FGfiSO.Mounting_Locations_only.xml : Labeling filter scheme to export only the Mounting Location Structure Identifiers * PDs.Mounting_Locations.xml : PDF export scheme. Relies on the PBfiN.Mounting_Locations.xml Page filter * PBfiN.Mounting_Locations.xml: Page filter based on a Mounting Location * * It also uses a "template" for the PBfiN.Mounting_Locations.xml Page filter. * It does string substitution to set a specific Mounting Location as the filter criteria. * After string substitution, the resulting Page filter scheme file is reloaded to set the desired ML * */ CommandLineInterpreter CLI = new CommandLineInterpreter(); ActionCallingContext ctx = new ActionCallingContext(); Settings set = new Settings(); try { //Load the PDF Export scheme. If a scheme with the same name already exists in P8, it will be overwritten. string pathPDFScheme = Path.Combine(PathMap.SubstitutePath("$(MD_SCHEME)"), "PDs.Mounting_Locations.xml"); set.ReadSettings(pathPDFScheme); //Load the Page Filter scheme. If a scheme with the same name already exists in P8, it will be overwritten. string pathFilterScheme = Path.Combine(PathMap.SubstitutePath("$(MD_SCHEME)"), "FGfiSO.Mounting_Locations_only.xml"); set.ReadSettings(pathFilterScheme); //Load the labeling scheme. If a scheme with the same name already exists in P8, it will be overwritten. string pathLabelingScheme = Path.Combine(PathMap.SubstitutePath("$(MD_SCHEME)"), "LB.Mounting_Location_List.xml"); string pathMLOutput = Path.Combine(PathMap.SubstitutePath("$(TMP)"), "AllMountingLocations.txt"); set.ReadSettings(pathLabelingScheme); //Export the project's Mounting Locations to temporary file, one per line ctx.AddParameter("configscheme", "Mounting_Location_List"); ctx.AddParameter("destinationfile", pathMLOutput); ctx.AddParameter("language", "en_US"); CLI.Execute("label", ctx); //Read the Mounting Location file as a List<string> for later iteration List <string> MLs = File.ReadLines(pathMLOutput).ToList(); string pathTemplate = Path.Combine(PathMap.SubstitutePath("$(MD_SCHEME)"), "PBfiN.Mounting_Locations_template.xml"); string pathPageFilterScheme = Path.Combine(PathMap.SubstitutePath("$(MD_SCHEME)"), "PBfiN.Mounting_Locations.xml"); //Loop through each Mounting Location in the "label" file foreach (string ML in MLs) { //Init Progress bar using (Progress prg = new Progress("SimpleProgress")) { prg.BeginPart(100, ""); prg.SetTitle("Exporting: " + ML); prg.SetAllowCancel(false); prg.ShowImmediately(); //Read the "template" file, and substitute the real Mounting Location string content = File.ReadAllText(pathTemplate); content = content.Replace("!!MountingLocation!!", ML); //Save the result back to disk, and load the resulting Page Filter scheme File.WriteAllText(pathPageFilterScheme, content); set.ReadSettings(pathPageFilterScheme); //Call the PDF export, using the scheme that makes use of the Page Filter ctx = new ActionCallingContext(); ctx.AddParameter("TYPE", "PDFPROJECTSCHEME"); ctx.AddParameter("EXPORTSCHEME", "Mounting_Locations"); ctx.AddParameter("EXPORTFILE", Path.Combine(rootFolder, ML)); CLI.Execute("export", ctx); prg.EndPart(true); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//Form_Load private void frmDocumentationTool_Load(object sender, System.EventArgs e) { //Position und Größe aus Settings lesen #if !DEBUG Eplan.EplApi.Base.Settings oSettings = new Eplan.EplApi.Base.Settings(); if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Top")) { this.Top = oSettings.GetNumericSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Top", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Left")) { this.Left = oSettings.GetNumericSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Left", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Height")) { this.Height = oSettings.GetNumericSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Height", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Width")) { this.Width = oSettings.GetNumericSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Width", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.toolStripMenuHerstellerVerzeichnis")) { this.toolStripMenuHerstellerVerzeichnis.Checked = oSettings.GetBoolSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.toolStripMenuHerstellerVerzeichnis", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.toolStripMenuArtikelnummerVerzeichnis")) { this.toolStripMenuArtikelnummerVerzeichnis.Checked = oSettings.GetBoolSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.toolStripMenuArtikelnummerVerzeichnis", 0); } #endif //Titelzeile anpassen string sProjekt = string.Empty; #if DEBUG sProjekt = "DEBUG"; #else CommandLineInterpreter cmdLineItp = new CommandLineInterpreter(); ActionCallingContext ProjektContext = new ActionCallingContext(); ProjektContext.AddParameter("TYPE", "PROJECT"); cmdLineItp.Execute("selectionset", ProjektContext); ProjektContext.GetParameter("PROJECT", ref sProjekt); sProjekt = Path.GetFileNameWithoutExtension(sProjekt); //Projektname Pfad und ohne .elk if (sProjekt == string.Empty) { Decider eDecision = new Decider(); EnumDecisionReturn eAnswer = eDecision.Decide(EnumDecisionType.eOkDecision, "Es ist kein Projekt ausgewählt.", "Documentation-Tool", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK); if (eAnswer == EnumDecisionReturn.eOK) { Close(); return; } } #endif Text = Text + " - " + sProjekt; //Button Extras Text festlegen //btnExtras.Text = " Extras ▾"; // ▾ ▼ //Zielverzeichnis vorbelegen #if DEBUG txtZielverzeichnis.Text = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\Test"; #else txtZielverzeichnis.Text = PathMap.SubstitutePath(@"$(DOC)"); #endif // Temporären Dateinamen festlegen #if DEBUG string sTempFile = Path.Combine(Application.StartupPath, "tmp_Projekt_Export.epj"); #else string sTempFile = Path.Combine(PathMap.SubstitutePath(@"$(TMP)"), "tmpDocumentationTool.epj"); #endif //Projekt exportieren #if !DEBUG PXFexport(sTempFile); #endif //PXF Datei einlesen und in Listview schreiben PXFeinlesen(sTempFile); //PXF Datei wieder löschen #if !DEBUG File.Delete(sTempFile); #endif }
private void btnOk_Click(object sender, System.EventArgs e) { #region check_macro_to_use string macroFile; switch (cbFunctionDef.Text) { case "Artikelplatzierung, normales Bauteil": macroFile = MacroFileNamePartPlacement; break; case "Schrankbauteil, allgemein": macroFile = MacroFileNameCabinetPart; break; default: macroFile = MacroFileNameCabinetPart; break; } #endregion #region check_user_entries if (txtWidth.Text == string.Empty || txtHeight.Text == string.Empty || txtDepth.Text == string.Empty) { MessageBox.Show("Die folgenden Eingaben müssen gefüllt sein:\n\n'Breite'\n'Höhe'\n'Tiefe'", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion #region insert_eplan_macro if (File.Exists(macroFile)) { // Read Template string newMacro = File.ReadAllText(macroFile); // Replace newMacro = newMacro.Replace("$(Width)", txtWidth.Text.Replace(",", ".")); newMacro = newMacro.Replace("$(Hight)", txtHeight.Text.Replace(",", ".")); newMacro = newMacro.Replace("$(Depth)", txtDepth.Text.Replace(",", ".")); newMacro = newMacro.Replace("$(Partnumber)", txtPartnumber.Text); if (txtPartnumber.Text != string.Empty) { newMacro = newMacro.Replace("$(PartnumberCnt)", "1"); } else { newMacro = newMacro.Replace("$(PartnumberCnt)", "0"); } newMacro = newMacro.Replace("$(Description)", txtDescription.Text); // Macro string strMacroPathTemp = PathMap.SubstitutePath("$(TMP)") + @"\" + "InsertUniversalPart3D_TEMP.ema"; File.WriteAllText(strMacroPathTemp, newMacro); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("Name", "XMIaInsertMacro"); acc.AddParameter("filename", strMacroPathTemp); acc.AddParameter("variant", "0"); new CommandLineInterpreter().Execute("XGedStartInteractionAction", acc); } else { MessageBox.Show("Vorlage nicht gefunden:\n" + macroFile, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion Close(); }
public void ToggleUnitsAction() { Settings set = new Settings(); //Get the installation type, which is actually the unit system name that we defined as the default. //As far as I know, it will be either "mm" or "inch". string InstallTypeSettingName = "STATION.SYSTEM.MasterdataLanguage"; string InstallType = set.GetStringSetting(InstallTypeSettingName, 0);; //The idea is fairly straightforward. If we detect a metric installation, we must use specific Setting names. Conversely, //if we detect an Inch installation, we must then use the inch specific Setting names. if (string.IsNullOrEmpty(InstallType) || (InstallType != "mm" && InstallType != "inch")) { //If the InstallType is neither "mm" or "inch", then display an error dialog, and exit back to EPLAN. MessageBox.Show(string.Format("Can't read the {0} setting: ", InstallTypeSettingName)); return; } //Now that we do have an InstallType name, it will be used to concatenate Text to obtain the BaseUnitSettingType string BaseUnitSettingName = string.Format("USER.EnfMVC.DisplayUnitIDs.{0}.BaseUnit", InstallType); string DefaultGridSizeSettingName = string.Format("USER.GedViewer.{0}.DefaultGridSize", InstallType); string CurrentUnitSetting = set.GetStringSetting(BaseUnitSettingName, 0); if (string.IsNullOrEmpty(CurrentUnitSetting) || (CurrentUnitSetting != "mm" && CurrentUnitSetting != "inch")) { MessageBox.Show(string.Format("Can't read the {0} setting: {1}", BaseUnitSettingName, CurrentUnitSetting)); return; } if (CurrentUnitSetting == "mm") { set.SetStringSetting(BaseUnitSettingName, "inch", 0); set.SetDoubleSetting(DefaultGridSizeSettingName, 12.7, 4); set.SetDoubleSetting(DefaultGridSizeSettingName, 6.35, 3); set.SetDoubleSetting(DefaultGridSizeSettingName, 3.175, 2); set.SetDoubleSetting(DefaultGridSizeSettingName, 1.5875, 1); set.SetDoubleSetting(DefaultGridSizeSettingName, 0.3175, 0); } else if (CurrentUnitSetting == "inch") { set.SetStringSetting(BaseUnitSettingName, "mm", 0); set.SetDoubleSetting(DefaultGridSizeSettingName, 8, 4); set.SetDoubleSetting(DefaultGridSizeSettingName, 4, 3); set.SetDoubleSetting(DefaultGridSizeSettingName, 2, 2); set.SetDoubleSetting(DefaultGridSizeSettingName, 1, 1); set.SetDoubleSetting(DefaultGridSizeSettingName, 0.1, 0); } else { MessageBox.Show(string.Format("Can't read the {0} setting", CurrentUnitSetting)); return; } //Use a Command Line Interpreter to call the Action CommandLineInterpreter CLI = new CommandLineInterpreter(); ActionCallingContext ctx = new ActionCallingContext(); ctx.AddParameter("Id", "4"); CLI.Execute("XGedSetGridsizeAction", ctx); }
//Button OK Click private void CreateCableDuct() { string sbuf; //Level of comment (A411 = 519(EPLAN519, Graphic.Comment)) string sEbene = "519"; //Linetype of the comment(A412 = L(Layer) / 0(pulled through) / 41(~~~~~)) string sLinientyp = "0"; //Pattern length of the comment (A415 = L(Layer) / -1.5(1,50 mm) / -32(32,00 mm)) string sPatternLenght = "-1.5"; //Color of the comment (A413 = 0 (black) / 1 (red) / 2 (yellow) / 3 (light green) / 4 (light blue) / 5 (dark blue) / 6 (violet) / 8 (white) / 40 (orange) / -4 Watermark / -5 Inverse to background) string sFarbe = "-4"; //Fill the surface string sFill = "1"; double dStartX = 64; double dStartY = 248; string sAngle = ""; string sLineThickness = "2"; if (dataGridView1.SelectedRows[0].Cells["LineThicknessColumn"].Value != null) { sLineThickness = dataGridView1.SelectedRows[0].Cells["LineThicknessColumn"].Value.ToString(); } //A966 = Alignment 0 = Layer, 4 = Middle Left, 5 = Middle centre string sAlignment = "5"; //A503 = Centered , 256 = All , 128 = First text string sCentered = "256"; //Text size string sTexteSize = "5"; if (dataGridView1.SelectedRows[0].Cells["TextSizeColumn"].Value != null) { sTexteSize = dataGridView1.SelectedRows[0].Cells["TextSizeColumn"].Value.ToString(); } //Size if (dataGridView1.SelectedRows[0].Cells["WidthColumn"].Value != null) { sbuf = dataGridView1.SelectedRows[0].Cells["WidthColumn"].Value.ToString(); } else { return; } double dWidth = double.Parse(sbuf); double dHeight = double.Parse(textBoxHeight.Text); //CableDuctText (A511) string sCableDuctText = ""; string sCableDuctTextEnglish, sCableDuctTextEnv; if (dataGridView1.SelectedRows[0].Cells["EnglishColumn"].Value != null) { sCableDuctTextEnglish = dataGridView1.SelectedRows[0].Cells["EnglishColumn"].Value.ToString(); } else { return; } if (dataGridView1.SelectedRows[0].Cells["EnvironnementColumn"].Value != null) { sCableDuctTextEnv = dataGridView1.SelectedRows[0].Cells["EnvironnementColumn"].Value.ToString(); } else { return; } if (!string.IsNullOrWhiteSpace(textBoxDescription.Text)) { sCableDuctTextEnglish = sCableDuctTextEnglish + " " + textBoxDescription.Text; // sCableDuctTextEnv = sCableDuctTextEnv + " " + textBoxDescription.Text; // } sCableDuctText = "en_US@" + sCableDuctTextEnglish + ";fr_FR@" + sCableDuctTextEnv + ";"; //??_??@" + sCableDuctTextEnv + ";"; /*if (sCableDuctText.EndsWith(Environment.NewLine)) //Kommentar darf nicht mit Zeilenumbruch enden * { sCableDuctText = sCableDuctText.Substring(0, sCableDuctText.Length - 2); } * sCableDuctText = sCableDuctText.Replace(Environment.NewLine, " "); //Kommentar Zeilenumbruch umwandeln * sCableDuctText = "??_??@" + sCableDuctText; //Kommentar MultiLanguage String * if (!sCableDuctText.EndsWith(";")) //Kommentar muss mit ";" enden * { sCableDuctText += ";"; }*/ //Pfad und Dateiname der Temp.datei string sTempFile; #if DEBUG sTempFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\tmpInsertCableDuct.ema"; #else sTempFile = PathMap.SubstitutePath(@"$(TMP)") + @"\tmpInsertCableDuct.ema"; #endif XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter writer = XmlWriter.Create(sTempFile, settings); //Macro file content writer.WriteRaw("\n<EplanPxfRoot Name=\"#Kommentar\" Type=\"WindowMacro\" Version=\"2.2.6360\" PxfVersion=\"1.23\" SchemaVersion=\"1.7.6360\" Source=\"\" SourceProject=\"\" Description=\"\" ConfigurationFlags=\"0\" NumMainObjects=\"0\" NumProjectSteps=\"0\" NumMDSteps=\"0\" Custompagescaleused=\"true\" StreamSchema=\"EBitmap,BaseTypes,2,1,2;EPosition3D,BaseTypes,0,3,2;ERay3D,BaseTypes,0,4,2;EStreamableVector,BaseTypes,0,5,2;DMNCDataSet,TrDMProject,1,20,2;DMNCDataSetVector,TrDMProject,1,21,2;DMPlaceHolderRuleData,TrDMProject,0,22,2;Arc3d@W3D,W3dBaseGeometry,0,36,2;Box3d@W3D,W3dBaseGeometry,0,37,2;Circle3d@W3D,W3dBaseGeometry,0,38,2;Color@W3D,W3dBaseGeometry,0,39,2;ContourPlane3d@W3D,W3dBaseGeometry,0,40,2;CTexture@W3D,W3dBaseGeometry,0,41,2;CTextureMap@W3D,W3dBaseGeometry,0,42,2;Line3d@W3D,W3dBaseGeometry,0,43,2;Linetype@W3D,W3dBaseGeometry,0,44,2;Material@W3D,W3dBaseGeometry,3,45,2;Path3d@W3D,W3dBaseGeometry,0,46,2;Mesh3dX@W3D,W3dMeshModeller,2,47,2;MeshBox@W3D,W3dMeshModeller,5,48,2;MeshMate@W3D,W3dMeshModeller,7,49,2;MeshMateFace@W3D,W3dMeshModeller,1,50,2;MeshMateGrid@W3D,W3dMeshModeller,8,51,2;MeshMateGridLine@W3D,W3dMeshModeller,1,52,2;MeshMateLine@W3D,W3dMeshModeller,1,53,2;MeshText3dX@W3D,W3dMeshModeller,0,55,2;BaseTextLine@W3D,W3dMeshModeller,2,56,2;Mesh3d@W3D,W3dMeshModeller,8,57,2;MeshEdge3d@W3D,W3dMeshModeller,0,58,2;MeshFace3d@W3D,W3dMeshModeller,2,59,2;MeshPoint3d@W3D,W3dMeshModeller,1,60,2;MeshPolygon3d@W3D,W3dMeshModeller,1,61,2;MeshSimpleTextureTriangle3d@W3D,W3dMeshModeller,2,62,2;MeshSimpleTriangle3d@W3D,W3dMeshModeller,1,63,2;MeshTriangle3d@W3D,W3dMeshModeller,2,64,2;MeshTriangleFace3d@W3D,W3dMeshModeller,0,65,2;MeshTriangleFaceEdge3D@W3D,W3dMeshModeller,0,66,2\">"); writer.WriteRaw("\n <MacroVariant MacroFuncType=\"1\" VariantId=\"0\" ReferencePoint=\"64/248/0\" Version=\"2.2.6360\" PxfVersion=\"1.23\" SchemaVersion=\"1.7.6360\" Source=\"\" SourceProject=\"\" Description=\"\" ConfigurationFlags=\"0\" DocumentType=\"1\" Customgost=\"0\">"); writer.WriteRaw("\n <O4 Build=\"6360\" A1=\"4/18\" A3=\"0\" A13=\"0\" A14=\"0\" A47=\"1\" A48=\"1362057551\" A50=\"1\" A59=\"1\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A431=\"1\" A1101=\"17\" A1102=\"\" A1103=\"\">"); //If you want to group writer.WriteRaw("\n <O26 Build=\"6360\" A1=\"26/128740\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A431=\"1\">"); //Properties CableDuct //Rectangle Property //A1656 = fill the surface //A1655 = radius //A1654 = round corner //A1653 = angle //A1651 = x / y statt //A1652 = x / y end //A406 = invisible //A411 = Layer //A414 = Line thickness //A415 = Pattern length //A416 = Line end style (1 = Rectangle) //A1657 //Wateramrk rectangle sFarbe = "-4"; // Watermark //sPatternLenght = "L"; writer.WriteRaw("\n <O89 Build=\"9661\" A1=\"89/339\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"100\" A412=\"" + sLinientyp + "\" A413=\"" + sFarbe + "\" A414=\"" + sLineThickness + "\" A415=\"" + sPatternLenght + "\" A416=\"0\" A1651=\"64/248\" A1652=\"" + Convert.ToString(dWidth + dStartX) + "/" + Convert.ToString(dHeight + dStartY) + "\" A1653=\"0\" A1654=\"0\" A1655=\"0\" A1656=\"" + sFill + "\" A1657=\" 0\" />"); //Border rectangle //sPatternLenght = "-10.0"; sFarbe = "-5"; //Inverse background //sLineThickness = "5"; writer.WriteRaw("\n <O89 Build=\"9661\" A1=\"89/339\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"100\" A412=\"" + sLinientyp + "\" A413=\"" + sFarbe + "\" A414=\"" + sLineThickness + "\" A415=\"" + sPatternLenght + "\" A416=\"0\" A1651=\"64/248\" A1652=\"" + Convert.ToString(dWidth + dStartX) + "/" + Convert.ToString(dHeight + dStartY) + "\" A1653=\"0\" A1654=\"0\" A1655=\"0\" A1656=\"0\" A1657=\" 0\" />"); //Properties text //A411 = Layer //A413 = Color //A503 = Centered , 256 = All , 128 = First text //A501 = Ref position //A966 = Alignment 0 = Layer, 4 = Middle Left, 5 = Middle centre //A961 = Text size //A962 = Angle (radian), L = Layer //A964 = Color too //A511 = Texte ="en_US@angalsi;fr_FR@francais;" //sCableDuctText = "en_US@angalsi;fr_FR@francais;"; double dAngle = 90 * 3.1416 / 180; sAngle = dAngle.ToString(); writer.WriteRaw("\n <O30 Build=\"9661\" A1=\"30/11504\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"33\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"108\" A412=\"L\" A413=\"-5\" A414=\"L\" A415=\"L\" A416=\"0\" A501=\"" + Convert.ToString(dWidth / 2 + dStartX) + "/" + Convert.ToString(dHeight / 2 + dStartY) + "\" A503=\"" + sCentered + "\" A506=\"0\" A511=\"" + sCableDuctText + "\">"); writer.WriteRaw("\n <S54x505 A961=\"" + sTexteSize + "\" A962=\"" + sAngle + "\" A963=\"0\" A964=\"-5\" A965=\"16384\" A966=\"" + sAlignment + "\" A967=\"8.48\" A968=\"3.75\" A969=\"0\" A4000=\"L\" A4001=\"L\" A4013=\"0\"/>"); writer.WriteRaw("\n </O30>"); //If you want to group writer.WriteRaw("\n </O26>"); writer.WriteRaw("\n <O37 Build=\"6360\" A1=\"37/128743\" A3=\"1\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A682=\"1\" A683=\"26/128740\" A684=\"0\" A687=\"8\" A688=\"2\" A689=\"-1\" A690=\"-1\" A691=\"0\" A693=\"1\" A792=\"0\" A793=\"0\" A794=\"0\" A1261=\"0\" A1262=\"44\" A1263=\"0\" A1631=\"0/-6.34911032028501\" A1632=\"8/0\">"); writer.WriteRaw("\n <S109x692 Build=\"6360\" A3=\"0\" A13=\"0\" A14=\"0\" R1906=\"165/128741\"/>"); writer.WriteRaw("\n <S109x692 Build=\"6360\" A3=\"0\" A13=\"0\" A14=\"0\" R1906=\"30/128742\"/>"); writer.WriteRaw("\n <S40x1201 A762=\"64/254.349110320285\">"); writer.WriteRaw("\n <S39x761 A751=\"1\" A752=\"0\" A753=\"0\" A754=\"1\"/>"); writer.WriteRaw("\n </S40x1201>"); writer.WriteRaw("\n <S89x5 Build=\"6360\" A3=\"0\" A4=\"1\" R7=\"37/128743\" A13=\"0\" A14=\"0\" A404=\"9\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"308\" A412=\"L\" A413=\"L\" A414=\"L\" A415=\"L\" A416=\"0\" A1651=\"0/-6.34911032028501\" A1652=\"8/0\" A1653=\"0\" A1654=\"0\" A1655=\"0\" A1656=\"0\" A1657=\"0\"/>"); writer.WriteRaw("\n </O37>"); writer.WriteRaw("\n </O4>"); writer.WriteRaw("\n </MacroVariant>"); writer.WriteRaw("\n</EplanPxfRoot>"); // Write the XML to file and close the writer. writer.Flush(); writer.Close(); //Makro einfügen #if DEBUG MessageBox.Show(sTempFile); #else CommandLineInterpreter oCli = new CommandLineInterpreter(); ActionCallingContext oAcc = new ActionCallingContext(); oAcc.AddParameter("Name", "XMIaInsertMacro"); oAcc.AddParameter("filename", sTempFile); oAcc.AddParameter("variant", "0"); oCli.Execute("XGedStartInteractionAction", oAcc); #endif //Beenden Close(); return; }
public bool Enabled(string strActionName, ActionCallingContext actionContext) { SelectionSet selection = new SelectionSet(); return(selection.Selection.OfType <Function>().Count() > 0); }
//Button OK Click private void btnOK_Click(object sender, System.EventArgs e) { //Level of Comment(A411 = 519(EPLAN519, Graphics.Comment)) string sLevel = "519"; //Linetype of Comment(A412 = L(Layer) / 0(solid) / 41(~~~~~)) string sLinetype = "41"; //Pattern length of the comment(A415 = L(layer) / -1.5(1.50 mm) / -32(32.00 mm)) string sMusterlänge = "-1.5"; //Comment color (A413 = 0(black) / 1(red) / 2(yellow) / 3(light green) / 4(light blue) / 5(dark blue) / 6(violet) / 8(white) / 40(orange)) string sColor = "40"; //Author (A2521) string sAuthor = txtWriter.Text; //Creation Date (A2524) string sCreationDate = DateTimeToUnixTimestamp(dCreationDate.Value).ToString(); // Convert DateTime value to Unix Timestamp format //Comment Text (A511) string sCommenttext = txtCommentext.Text; if (sCommenttext.EndsWith(Environment.NewLine)) //Comment can not end with a line break { sCommenttext = sCommenttext.Substring(0, sCommenttext.Length - 2); } sCommenttext = sCommenttext.Replace(Environment.NewLine, " "); //Comment Convert line break sCommenttext = "??_??@" + sCommenttext; //Comment MultiLanguage String if (!sCommenttext.EndsWith(";")) //Comment must be with ";" end up { sCommenttext += ";"; } //Status, (A2527 = 0 (no status) / 1 (Accepted) / 2 (Declined) / 3 (Canceled) / 4 (Finished)) string sStatus = cBStatus.SelectedIndex.ToString(); //Path and filename of the Temp.file string sTempFile; #if DEBUG sTempFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\tmpInsertComment.ema"; #else sTempFile = PathMap.SubstitutePath(@"$(TMP)") + @"\tmpInsertComment.ema"; #endif XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter writer = XmlWriter.Create(sTempFile, settings); //Macro file content writer.WriteRaw("\n<EplanPxfRoot Name=\"#Comment\" Type=\"WindowMacro\" Version=\"2.2.6360\" PxfVersion=\"1.23\" SchemaVersion=\"1.7.6360\" Source=\"\" SourceProject=\"\" Description=\"\" ConfigurationFlags=\"0\" NumMainObjects=\"0\" NumProjectSteps=\"0\" NumMDSteps=\"0\" Custompagescaleused=\"true\" StreamSchema=\"EBitmap,BaseTypes,2,1,2;EPosition3D,BaseTypes,0,3,2;ERay3D,BaseTypes,0,4,2;EStreamableVector,BaseTypes,0,5,2;DMNCDataSet,TrDMProject,1,20,2;DMNCDataSetVector,TrDMProject,1,21,2;DMPlaceHolderRuleData,TrDMProject,0,22,2;Arc3d@W3D,W3dBaseGeometry,0,36,2;Box3d@W3D,W3dBaseGeometry,0,37,2;Circle3d@W3D,W3dBaseGeometry,0,38,2;Color@W3D,W3dBaseGeometry,0,39,2;ContourPlane3d@W3D,W3dBaseGeometry,0,40,2;CTexture@W3D,W3dBaseGeometry,0,41,2;CTextureMap@W3D,W3dBaseGeometry,0,42,2;Line3d@W3D,W3dBaseGeometry,0,43,2;Linetype@W3D,W3dBaseGeometry,0,44,2;Material@W3D,W3dBaseGeometry,3,45,2;Path3d@W3D,W3dBaseGeometry,0,46,2;Mesh3dX@W3D,W3dMeshModeller,2,47,2;MeshBox@W3D,W3dMeshModeller,5,48,2;MeshMate@W3D,W3dMeshModeller,7,49,2;MeshMateFace@W3D,W3dMeshModeller,1,50,2;MeshMateGrid@W3D,W3dMeshModeller,8,51,2;MeshMateGridLine@W3D,W3dMeshModeller,1,52,2;MeshMateLine@W3D,W3dMeshModeller,1,53,2;MeshText3dX@W3D,W3dMeshModeller,0,55,2;BaseTextLine@W3D,W3dMeshModeller,2,56,2;Mesh3d@W3D,W3dMeshModeller,8,57,2;MeshEdge3d@W3D,W3dMeshModeller,0,58,2;MeshFace3d@W3D,W3dMeshModeller,2,59,2;MeshPoint3d@W3D,W3dMeshModeller,1,60,2;MeshPolygon3d@W3D,W3dMeshModeller,1,61,2;MeshSimpleTextureTriangle3d@W3D,W3dMeshModeller,2,62,2;MeshSimpleTriangle3d@W3D,W3dMeshModeller,1,63,2;MeshTriangle3d@W3D,W3dMeshModeller,2,64,2;MeshTriangleFace3d@W3D,W3dMeshModeller,0,65,2;MeshTriangleFaceEdge3D@W3D,W3dMeshModeller,0,66,2\">"); writer.WriteRaw("\n <MacroVariant MacroFuncType=\"1\" VariantId=\"0\" ReferencePoint=\"64/248/0\" Version=\"2.2.6360\" PxfVersion=\"1.23\" SchemaVersion=\"1.7.6360\" Source=\"\" SourceProject=\"\" Description=\"\" ConfigurationFlags=\"0\" DocumentType=\"1\" Customgost=\"0\">"); writer.WriteRaw("\n <O4 Build=\"6360\" A1=\"4/18\" A3=\"0\" A13=\"0\" A14=\"0\" A47=\"1\" A48=\"1362057551\" A50=\"1\" A59=\"1\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A431=\"1\" A1101=\"17\" A1102=\"\" A1103=\"\">"); //if you want to group if (chkCommentTextGroup.Checked == true) { writer.WriteRaw("\n <O26 Build=\"6360\" A1=\"26/128740\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A431=\"1\">"); } //Characteristics Comment writer.WriteRaw("\n <O165 Build=\"6360\" A1=\"165/128741\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"" + sLevel + "\" A412=\"" + sLinetype + "\" A413=\"" + sColor + "\" A414=\"0.352777238812552\" A415=\"" + sMusterlänge + "\" A416=\"0\" A501=\"64/248\" A503=\"0\" A504=\"0\" A506=\"22\" A511=\"" + sCommenttext + "\" A2521=\"" + sAuthor + "\" A2522=\"\" A2523=\"\" A2524=\"" + sCreationDate + "\" A2525=\"" + sCreationDate + "\" A2526=\"2\" A2527=\"" + sStatus + "\" A2528=\"0\" A2529=\"0\" A2531=\"0\" A2532=\"0\" A2533=\"64/248;70.349110320284/254.349110320285\" A2534=\"2\" A2539=\"0\" A2540=\"0\">"); writer.WriteRaw("\n <S54x505 A961=\"L\" A962=\"L\" A963=\"0\" A964=\"L\" A965=\"0\" A966=\"0\" A967=\"0\" A968=\"0\" A969=\"0\" A4000=\"L\" A4001=\"L\" A4013=\"0\"/>"); writer.WriteRaw("\n </O165>"); //Characteristics Text writer.WriteRaw("\n <O30 Build=\"6360\" A1=\"30/128742\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"" + sLevel + "\" A412=\"L\" A413=\"L\" A414=\"L\" A415=\"L\" A416=\"0\" A501=\"72/248\" A503=\"0\" A504=\"0\" A506=\"0\" A511=\"" + sCommenttext + "\">"); writer.WriteRaw("\n <S54x505 A961=\"L\" A962=\"L\" A963=\"0\" A964=\"L\" A965=\"0\" A966=\"0\" A967=\"0\" A968=\"0\" A969=\"0\" A4000=\"L\" A4001=\"L\" A4013=\"0\"/>"); writer.WriteRaw("\n </O30>"); //Ff you want to group if (chkCommentTextGroup.Checked == true) { writer.WriteRaw("\n </O26>"); } writer.WriteRaw("\n <O37 Build=\"6360\" A1=\"37/128743\" A3=\"1\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A682=\"1\" A683=\"26/128740\" A684=\"0\" A687=\"8\" A688=\"2\" A689=\"-1\" A690=\"-1\" A691=\"0\" A693=\"1\" A792=\"0\" A793=\"0\" A794=\"0\" A1261=\"0\" A1262=\"44\" A1263=\"0\" A1631=\"0/-6.34911032028501\" A1632=\"8/0\">"); writer.WriteRaw("\n <S109x692 Build=\"6360\" A3=\"0\" A13=\"0\" A14=\"0\" R1906=\"165/128741\"/>"); writer.WriteRaw("\n <S109x692 Build=\"6360\" A3=\"0\" A13=\"0\" A14=\"0\" R1906=\"30/128742\"/>"); writer.WriteRaw("\n <S40x1201 A762=\"64/254.349110320285\">"); writer.WriteRaw("\n <S39x761 A751=\"1\" A752=\"0\" A753=\"0\" A754=\"1\"/>"); writer.WriteRaw("\n </S40x1201>"); writer.WriteRaw("\n <S89x5 Build=\"6360\" A3=\"0\" A4=\"1\" R7=\"37/128743\" A13=\"0\" A14=\"0\" A404=\"9\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"308\" A412=\"L\" A413=\"L\" A414=\"L\" A415=\"L\" A416=\"0\" A1651=\"0/-6.34911032028501\" A1652=\"8/0\" A1653=\"0\" A1654=\"0\" A1655=\"0\" A1656=\"0\" A1657=\"0\"/>"); writer.WriteRaw("\n </O37>"); writer.WriteRaw("\n </O4>"); writer.WriteRaw("\n </MacroVariant>"); writer.WriteRaw("\n</EplanPxfRoot>"); // Write the XML to file and close the writer. writer.Flush(); writer.Close(); //Insert macro #if DEBUG MessageBox.Show(sTempFile); #else CommandLineInterpreter oCli = new CommandLineInterpreter(); ActionCallingContext oAcc = new ActionCallingContext(); oAcc.AddParameter("Name", "XMIaInsertMacro"); oAcc.AddParameter("filename", sTempFile); oAcc.AddParameter("variant", "0"); oCli.Execute("XGedStartInteractionAction", oAcc); #endif //Break up Close(); return; }
public void Action(string rootPath, string schemeName, string fileName, string tempFile, string projectPropertyLabelingScheme) //public void Action() { /* * It is not possible in EPLAN scripting to "read" or "get" project properties. This requires API. * * As workaround, we create a labeling scheme based on Table of Contents, which scheme will only output * a single value to a file, which is the property that we want to use as the "new folder" name. * * Said scheme must exist in EPLAN before this script can perform. * */ ActionManager oMngr = new Eplan.EplApi.ApplicationFramework.ActionManager(); Eplan.EplApi.ApplicationFramework.Action oSelSetAction = oMngr.FindAction("selectionset"); Eplan.EplApi.ApplicationFramework.Action oLabelAction = oMngr.FindAction("label"); //Verify if actions were found if (oSelSetAction == null || oLabelAction == null) { MessageBox.Show("Could not obtain actions"); return; } //ActionCallingContext is used to pass "parameters" into EPLAn Actions ActionCallingContext ctx = new ActionCallingContext(); //Using the "selectionset" Action, get the current project path, used later by labeling action ctx.AddParameter("TYPE", "PROJECT"); bool sRet = oSelSetAction.Execute(ctx); string sProject = ""; if (sRet) { ctx.GetParameter("PROJECT", ref sProject); } else { MessageBox.Show("Could not obtain project path"); return; } tempFile = string.Format(@"{0}\{1}", rootPath, tempFile); //MessageBox.Show(string.Format("{0}\r\n{1}\r\n{2}\r\n{3}\r\n", rootPath, schemeName, fileName, tempFile)); //Create a new ActionCallingCOntext to make sure we start with an empty one, //and then call the labeling action to obtain the desired project value, //which gets written to a temporary file. ctx = new ActionCallingContext(); ctx.AddParameter("PROJECTNAME", sProject); ctx.AddParameter("CONFIGSCHEME", projectPropertyLabelingScheme); ctx.AddParameter("LANGUAGE", "en_US"); ctx.AddParameter("DESTINATIONFILE", tempFile); oLabelAction.Execute(ctx); //Now read the temp file, and read the property that was writen to it by the labeling function. //Note: Which property gets written to the temp file is determined in the selected labeling scheme settings string[] tempContent = File.ReadAllLines(tempFile); File.Delete(tempFile); //Verify if file had content if (tempContent.Length == 0) { MessageBox.Show("Property file was empty"); return; } string projectProperty = tempContent[0]; //Verify if value is valid if (string.IsNullOrEmpty(projectProperty)) { MessageBox.Show("Could not obtain property value from file"); return; } string outputPath = string.Format(@"{0}\{1}\{2}", rootPath, projectProperty, fileName); //Create a new ActionCallingCOntext to make sure we start with an empty one, //and then call the labeling action to obtain the desired labeling output //to the desired folder. ctx = new ActionCallingContext(); ctx.AddParameter("PROJECTNAME", sProject); ctx.AddParameter("CONFIGSCHEME", schemeName); ctx.AddParameter("LANGUAGE", "en_US"); ctx.AddParameter("DESTINATIONFILE", outputPath); oLabelAction.Execute(ctx); }
public bool Execute(ActionCallingContext oActionCallingContext) { MessageBox.Show("Login Action"); return(true); }
//Button OK Click private void btnOK_Click(object sender, System.EventArgs e) { //Kommentar sichtbar (A404 = 0(Unsichtbar) / 33(Sichtbar)) string sSichtbar = "33"; //Ebene des Kommentar (A411 = 519(EPLAN519, Grafik.Kommentare)) string sEbene = "519"; //Linientyp des Kommentar (A412 = L(Layer) / 0(durchgezogen) / 41(~~~~~)) string sLinientyp = "41"; //Farbe des Kommentar (A413 = 0(schwarz) / 1(rot) / 2(gelb) / 3(hellgrün) / 4(hellblau) / 5(dunkelblau) / 6(violett) / 8(weiss) / 10(roter Kommentar) / 40(orange)) string sFarbe = "40"; //Musterlänge des Kommentar (A415 = L(Layer) / -1.5(1,50 mm) / -32(32,00 mm)) string sMusterlänge = "-1.5"; //Text Formatierung (A965 = 0(Standard) / 1(Fett) / 2(Kursiv) / 3(Kursiv+Fett) / 4(Unterstrichen) / 5(Fett+Unterstrichen) / 6(Unterstrichen+Kursiv) / 7(Fett+Unterstrichen+Kursiv) / 18432(mit Textrahmen) / 18434(mit Textrahmen + Kursiv)) string sSchriftstil = "2"; //Text Ausrichtung (A966 = 0(Text Unten links) / 4(Text Mitte links)) string sTextAusrichtung = "4"; //Text mit Rahmen (A969 = 0(Layer) / 1(Textrahmen Rechteck) / 2(mit Textrahmen, Größe aus Projekt) / -127(Textrahmen Oval (ab Eplan 2.5))) string sTextRahmen = "0"; //???? abhängig vom Schriftstil //Verfasser (A2521) string sVerfasser = txtVerfasser.Text; //Erstellungsdatum (A2524) string sErstellungsdatum = DateTimeToUnixTimestamp(dTPErstellungsdatum.Value).ToString(); // DateTime Wert nach Unix Timestamp Format wandeln //Kommentartext (A511) string sKommentartext = txtKommentartext.Text; if (sKommentartext.EndsWith(Environment.NewLine)) //Kommentar darf nicht mit Zeilenumbruch enden { sKommentartext = sKommentartext.Substring(0, sKommentartext.Length - 2); } sKommentartext = sKommentartext.Replace(Environment.NewLine, " "); //Kommentar Zeilenumbruch umwandeln sKommentartext = "??_??@" + sKommentartext; //Kommentar MultiLanguage String if (!sKommentartext.EndsWith(";")) //Kommentar muss mit ";" enden { sKommentartext += ";"; } //Status (A2527 = 0(kein Status) / 1(Akzeptiert) / 2(Abgelehnt) / 3(Abgebrochen) / 4(Beendet)) string sStatus = cBStatus.SelectedIndex.ToString(); //Pfad und Dateiname der Temp.datei string sTempFile; #if DEBUG sTempFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\tmpInsertComment.ema"; #else sTempFile = PathMap.SubstitutePath(@"$(TMP)") + @"\tmpInsertComment.ema"; #endif XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter writer = XmlWriter.Create(sTempFile, settings); //Makrodatei Inhalt writer.WriteRaw("\n<EplanPxfRoot Name=\"#Kommentar\" Type=\"WindowMacro\" Version=\"2.5.9380\" PxfVersion=\"1.23\" SchemaVersion=\"1.7.9380\" Source=\"\" SourceProject=\"\" Description=\"\" ConfigurationFlags=\"0\" NumMainObjects=\"0\" NumProjectSteps=\"0\" NumMDSteps=\"0\" Custompagescaleused=\"true\" StreamSchema=\"EBitmap,BaseTypes,2,1,2;EPosition3D,BaseTypes,0,3,2;ERay3D,BaseTypes,0,4,2;EStreamableVector,BaseTypes,0,5,2;DMNCDataSet,TrDMProject,1,20,2;DMNCDataSetVector,TrDMProject,1,21,2;DMPlaceHolderRuleData,TrDMProject,0,22,2;Arc3d@W3D,W3dBaseGeometry,0,36,2;Box3d@W3D,W3dBaseGeometry,0,37,2;Circle3d@W3D,W3dBaseGeometry,0,38,2;Color@W3D,W3dBaseGeometry,0,39,2;ContourPlane3d@W3D,W3dBaseGeometry,0,40,2;CTexture@W3D,W3dBaseGeometry,0,41,2;CTextureMap@W3D,W3dBaseGeometry,0,42,2;Line3d@W3D,W3dBaseGeometry,0,43,2;Linetype@W3D,W3dBaseGeometry,0,44,2;Material@W3D,W3dBaseGeometry,3,45,2;Path3d@W3D,W3dBaseGeometry,0,46,2;Mesh3dX@W3D,W3dMeshModeller,2,47,2;MeshBox@W3D,W3dMeshModeller,5,48,2;MeshMate@W3D,W3dMeshModeller,7,49,2;MeshMateFace@W3D,W3dMeshModeller,1,50,2;MeshMateGrid@W3D,W3dMeshModeller,8,51,2;MeshMateGridLine@W3D,W3dMeshModeller,1,52,2;MeshMateLine@W3D,W3dMeshModeller,1,53,2;MeshText3dX@W3D,W3dMeshModeller,0,55,2;BaseTextLine@W3D,W3dMeshModeller,2,56,2;Mesh3d@W3D,W3dMeshModeller,8,57,2;MeshEdge3d@W3D,W3dMeshModeller,0,58,2;MeshFace3d@W3D,W3dMeshModeller,2,59,2;MeshPoint3d@W3D,W3dMeshModeller,1,60,2;MeshPolygon3d@W3D,W3dMeshModeller,1,61,2;MeshSimpleTextureTriangle3d@W3D,W3dMeshModeller,2,62,2;MeshSimpleTriangle3d@W3D,W3dMeshModeller,1,63,2;MeshTriangle3d@W3D,W3dMeshModeller,2,64,2;MeshTriangleFace3d@W3D,W3dMeshModeller,0,65,2;MeshTriangleFaceEdge3D@W3D,W3dMeshModeller,0,66,2\">"); writer.WriteRaw("\n <MacroVariant MacroFuncType=\"1\" VariantId=\"0\" ReferencePoint=\"64/248/0\" Version=\"2.5.9380\" PxfVersion=\"1.23\" SchemaVersion=\"1.7.6360\" Source=\"\" SourceProject=\"\" Description=\"\" ConfigurationFlags=\"0\" DocumentType=\"1\" Customgost=\"0\">"); writer.WriteRaw("\n <O4 Build=\"9380\" A1=\"4/6\" A3=\"0\" A13=\"0\" A14=\"0\" A47=\"1\" A48=\"1362057551\" A50=\"48\" A59=\"1\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A431=\"1\" A1101=\"1\" A1102=\"\" A1103=\"\" A4043=\"0\" A4049=\"0\">"); //Text als Kommentar ausgegeben //Eigenschaften Text (als O165, anstatt O30, damit der Text als Kommentar gilt + Ausgabe Kommentar ab A2521) // A501 = 64/248(relativer Abstand zum Cursor, muß so stehen damit direkt am Cursor hängt und alle Größen passen) // A2535 = 62/252(Startpunkt X-Koordinate / Startpunkt Y-Koordinate) // A2536 = 54/244(Endpunkt X-Koordinate / Endpunkt Y-Koordinate) writer.WriteRaw("\n <O165 Build=\"9380\" A1=\"165/3280\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"" + sSichtbar + "\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"" + sEbene + "\" A412=\"" + sLinientyp + "\" A413=\"" + sFarbe + "\" A414=\"L\" A415=\"" + sMusterlänge + "\" A416=\"0\" A501=\"64/248\" A503=\"0\" A506=\"0\" A511=\"" + sKommentartext + "\" A2521=\"" + sVerfasser + "\" A2522=\"\" A2523=\"\" A2524=\"" + sErstellungsdatum + "\" A2525=\"" + sErstellungsdatum + "\" A2526=\"0\" A2527=\"" + sStatus + "\" A2528=\"0\" A2529=\"0\" A2531=\"0\" A2532=\"0\" A2534=\"0\" A2535=\"62/252\" A2536=\"54/244\" A2539=\"0\" A2540=\"0\">"); writer.WriteRaw("\n <S54x505 A961=\"L\" A962=\"L\" A963=\"0\" A964=\"L\" A965=\"" + sSchriftstil + "\" A966=\"" + sTextAusrichtung + "\" A967=\"0\" A968=\"0\" A969=\"" + sTextRahmen + "\" A4000=\"L\" A4001=\"L\" A4013=\"0\"/>"); writer.WriteRaw("\n </O165>"); //Makrodatei Inhalt writer.WriteRaw("\n <O37 Build=\"9380\" A1=\"37/3281\" A3=\"1\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A682=\"1\" A683=\"165/3280\" A684=\"0\" A687=\"8\" A688=\"2\" A689=\"-1\" A690=\"-1\" A691=\"0\" A693=\"1\" A695=\"0\" A792=\"0\" A793=\"0\" A794=\"0\" A1261=\"0\" A1262=\"44\" A1263=\"0\" A1651=\"0/-248\" A1652=\"64/0\">"); writer.WriteRaw("\n <S109x692 R1906=\"165/3280\"/>"); writer.WriteRaw("\n <S40x1201 A762=\"64/248\">"); writer.WriteRaw("\n <S39x761 A751=\"1\" A752=\"0\" A753=\"0\" A754=\"1\"/>"); writer.WriteRaw("\n </S40x1201>"); writer.WriteRaw("\n <S89x5 Build=\"9380\" A3=\"0\" A4=\"1\" R7=\"37/3281\" A13=\"0\" A14=\"0\" A189=\"0\" A404=\"9\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"308\" A412=\"L\" A413=\"L\" A414=\"L\" A415=\"L\" A416=\"0\" A1651=\"0/0\" A1652=\"0/0\" A1653=\"0\" A1654=\"0\" A1655=\"0\" A1656=\"0\" A1657=\"0\"/>"); writer.WriteRaw("\n </O37>"); writer.WriteRaw("\n </O4>"); writer.WriteRaw("\n </MacroVariant>"); writer.WriteRaw("\n</EplanPxfRoot>"); // Write the XML to file and close the writer. writer.Flush(); writer.Close(); //Makro einfügen #if DEBUG MessageBox.Show(sTempFile); #else CommandLineInterpreter oCli = new CommandLineInterpreter(); ActionCallingContext oAcc = new ActionCallingContext(); oAcc.AddParameter("Name", "XMIaInsertMacro"); oAcc.AddParameter("filename", sTempFile); oAcc.AddParameter("variant", "0"); oCli.Execute("XGedStartInteractionAction", oAcc); #endif //Beenden Close(); return; }
public bool Execute(ActionCallingContext oActionCallingContext) { // MessageBox.Show("Checkout Action"); SelectionSet selectionSet = new SelectionSet(); Project project = selectionSet.GetCurrentProject(true); //string creator = project.Properties[10013]; //MessageBox.Show(creator); //Location[] location = project.GetLocationObjects(Project.Hierarchy.Plant); //string strDesc1 = ISOCodeUtil.GetISOStringValue(location[0].Properties.LOCATION_DESCRIPTION_SUPPLEMENTARYFIELD[1]); //MessageBox.Show(strDesc1); Page[] pages = project.Pages; DMObjectsFinder finder = new DMObjectsFinder(project); PagePropertyList ppl = new PagePropertyList(); // ppl.DESIGNATION_LOCATION = "C1"; // ppl.DESIGNATION_DOCTYPE = "SINGLE"; // ppl.DESIGNATION_DOCTYPE = "MULTI"; ppl.PAGE_TYPE_NUMERIC = 1; PagesFilter pf = new PagesFilter(); pf.SetFilteredPropertyList(ppl); Page[] sPages = finder.GetPages(pf); // sPages[0]. //FunctionPropertyList fpl = new FunctionPropertyList(); //FunctionsFilter ff = new FunctionsFilter(); //ff.SetFilteredPropertyList() ArrayList list = new ArrayList(); Function[] ffss = finder.GetFunctions(null); foreach (Function f in ffss) { if (f.Category == Function.Enums.Category.Motor) { list.Add(f); ArticleReference[] ars = f.ArticleReferences; if (ars.Count() > 0) { int count = ars[0].Count; Article article = ars[0].Article; } } } ArticleReferencePropertyList arpl = new ArticleReferencePropertyList(); arpl.ARTICLE_MANUFACTURER = "RITTAL"; ArticleReferencesFilter arf = new ArticleReferencesFilter(); arf.SetFilteredPropertyList(arpl); ArticleReference[] fars = finder.GetArticleReferences(arf); foreach (ArticleReference item in fars) { // MessageBox.Show(string.Format("{0}[{1}]({2})", item.Properties.ARTICLEREF_PARTNO, item.Properties.ARTICLE_MANUFACTURER, item.Count)); } // ArticleReference[] farsws = finder.GetArticleReferencesWithFilterScheme("default"); // P8에서 정의한 스키마로 필터 //PagePropertyList newppl = new PagePropertyList(); //// newppl.DESIGNATION_LOCATION = "MULTI"; //newppl.DESIGNATION_DOCTYPE = "MULTI"; //newppl.PAGE_COUNTER = "11"; //newppl.PAGE_NOMINATIOMN = "Insert Macro By API"; //newppl.PAGE_IDENTNAME = "1011"; //newppl.PAGE_NUMBER = "11"; //newppl.PAGE_NAME = "Insert Macro By API"; //Page newPage = new Page(); //newPage.Create(project, DocumentTypeManager.DocumentType.Circuit, newppl); //Insert insert = new Insert(); //PointD point = new PointD(100, 250); //var resultObject = insert.WindowMacro(@"C:\Users\Public\EPLAN26\Data\Macros\EPlanKorea\m.ema", 0, newPage, point, Insert.MoveKind.Absolute); PagePropertyList newppl = new PagePropertyList(); newppl.DESIGNATION_DOCTYPE = "MULTI"; newppl.PAGE_COUNTER = "211"; newppl.PAGE_NOMINATIOMN = "Insert Page Macro By API"; newppl.PAGE_IDENTNAME = "2011"; newppl.PAGE_NUMBER = "211"; newppl.PAGE_NAME = "Insert Page Macro By API"; Page newPage = new Page(); newPage.Create(project, DocumentTypeManager.DocumentType.Circuit, newppl); Insert insert = new Insert(); var resultObject = insert.PageMacro(@"C:\Users\Public\EPLAN26\Data\Macros\EPlanKorea\mPage.emp", newPage, project, false, PageMacro.Enums.NumerationMode.Number); return(true); }
/// <summary> /// Execution of the Action. /// </summary> /// <returns>True: Execution of the Action was successful</returns> public bool Execute(ActionCallingContext ctx) { MessageDisplayHelper.Show("ActionApiExtPopupMenu was called", "ActionApiExtPopupMenu"); return(true); }
//[Start] public void Export_Txt_Fehlworte() { //======================================================================= // Dialogabfrage const string message = "Prüfung von fehlenden Übersetzungen durchführen?"; const string caption = "Export Fehlworteliste"; var result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } //======================================================================= // aktuelles Projektpfad ermitteln string sProject = Get_Project(); //sProject = sProject.Replace("File-2", "K-ELT-01"); if (sProject == "") { MessageBox.Show("Projekt auswählen !"); return; } //MessageBox.Show(sProject); // Projektname ermitteln string strProjectname = Get_Name(sProject); //======================================================================= //eingestellte Projektsprache EPLAN ermitteln string strDisplayLanguage = null; ActionCallingContext ACCDisplay = new ActionCallingContext(); new CommandLineInterpreter().Execute("GetDisplayLanguage", ACCDisplay); ACCDisplay.GetParameter("value", ref strDisplayLanguage); //MessageBox.Show("Language : " + strDisplayLanguage); //======================================================================= //Fehlworteliste erzeugen : Eplan.EplApi.ApplicationFramework.ActionCallingContext acctranslate = new Eplan.EplApi.ApplicationFramework.ActionCallingContext(); Eplan.EplApi.ApplicationFramework.CommandLineInterpreter CLItranslate = new Eplan.EplApi.ApplicationFramework.CommandLineInterpreter(); Eplan.EplApi.Base.Progress progress = new Eplan.EplApi.Base.Progress("SimpleProgress"); progress.BeginPart(100, ""); progress.SetAllowCancel(true); string MisTranslateFile = @"c:\TEMP\EPLAN\EPLAN_Fehlworteliste_" + strProjectname + "_" + strDisplayLanguage + ".txt"; acctranslate.AddParameter("TYPE", "EXPORTMISSINGTRANSLATIONS"); acctranslate.AddParameter("LANGUAGE", strDisplayLanguage); acctranslate.AddParameter("EXPORTFILE", MisTranslateFile); acctranslate.AddParameter("CONVERTER", "XTrLanguageDbXml2TabConverterImpl"); bool sRet = CLItranslate.Execute("translate", acctranslate); if (!sRet) { MessageBox.Show("Fehler bei Export fehlende Übersetzungen!"); return; } // MessageBox.Show("Fehlende Übersetzungen exportiert in : " + MisTranslateFile); //================================================================= //Fehlworteliste lesen und Zeilenanzahl ermitteln : int counter = 0; string line; if (File.Exists(MisTranslateFile)) { using (StreamReader countReader = new StreamReader(MisTranslateFile)) { while (countReader.ReadLine() != null) { counter++; } } // MessageBox.Show("Zeilenanzahl in " + MisTranslateFile + " : " + counter); if (counter > 1) //================================================================= //Fehlworteliste öffnen falls Zeilenanzahl > 1 : { // MessageBox.Show("Fehlende Übersetzungen gefunden !"); // Open the txt file with missing translation System.Diagnostics.Process.Start("notepad.exe", MisTranslateFile); } } progress.EndPart(true); return; }
public bool Execute(ActionCallingContext oActionCallingContext) { Test.Library.MergeTest.Normal(); return(true); }
public bool MyMacroBoxName(string EXTENSION, string GETNAMEFROMLEVEL) { //parameter description: //---------------------- //EXTENSION ... macroname extionsion (e.g. '.ems') // GETNAMEFROMLEVEL ... get macro name form level code (eg 1 = Functional assignment, 2 = Attachment, 3 = Location, 4 = Location, 5 = Document type, 6 = User defined, P = Page name) try { string sPages = string.Empty; ActionCallingContext oCTX1 = new ActionCallingContext(); CommandLineInterpreter oCLI1 = new CommandLineInterpreter(); oCTX1.AddParameter("TYPE", "PAGES"); oCLI1.Execute("selectionset", oCTX1); oCTX1.GetParameter("PAGES", ref sPages); string[] sarrPages = sPages.Split(';'); if (sarrPages.Length > 1) { MessageBox.Show("More than one page marked. \nAction not possible......", "Note..."); return(false); } #region get macroname string sPageName = sarrPages[0]; // ensure unique level codes: // Functional assignment -> $ // Site ->% sPageName = sPageName.Replace("==", "$").Replace("++", "%"); //get location from pagename string sMacroBoxName = string.Empty; //add needed / wanted structures to macroname #region generate macroname string[] sNeededLevels = GETNAMEFROMLEVEL.Split('|'); foreach (string sLevel in sNeededLevels) { switch (sLevel) { case "1": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName += ExtractLevelName(sPageName, "$"); } else { sMacroBoxName += "\\" + ExtractLevelName(sPageName, "$"); } break; case "2": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName += ExtractLevelName(sPageName, "="); } else { sMacroBoxName += "\\" + ExtractLevelName(sPageName, "="); } break; case "3": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "%"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "%"); } break; case "4": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "+"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "+"); } break; case "5": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "&"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "&"); } break; case "6": if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "#"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "#"); } break; case "P": //Page name if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName + ExtractLevelName(sPageName, "/"); } else { sMacroBoxName = sMacroBoxName + "\\" + ExtractLevelName(sPageName, "/"); } break; default: break; } } #endregion //Clean-up macroname if (sMacroBoxName.EndsWith(@"\")) { sMacroBoxName = sMacroBoxName.Remove(sMacroBoxName.Length - 1, 1); } if (sMacroBoxName.StartsWith(@"\")) { sMacroBoxName = sMacroBoxName.Substring(1); } if (sMacroBoxName == string.Empty) { MessageBox.Show("No macro name could be determined...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } sMacroBoxName = sMacroBoxName.Replace(".", @"\") + EXTENSION; #endregion //set macrobox: macroname string quote = "\""; CommandLineInterpreter oCLI2 = new CommandLineInterpreter(); oCLI2.Execute("XEsSetPropertyAction /PropertyId:23001 /PropertyIndex:0 /PropertyValue:" + quote + sMacroBoxName + quote); return(true); } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
//Button OK Click private void btnOK_Click(object sender, System.EventArgs e) { //Ebene des Kommentar (A411 = 519(EPLAN519, Grafik.Kommentare)) string sEbene = "519"; //Linientyp des Kommentar (A412 = L(Layer) / 0(durchgezogen) / 41(~~~~~)) string sLinientyp = "41"; //Musterlänge des Kommentar (A415 = L(Layer) / -1.5(1,50 mm) / -32(32,00 mm)) string sMusterlänge = "-1.5"; //Farbe des Kommentar (A413 = 0(schwarz) / 1(rot) / 2(gelb) / 3(hellgrün) / 4(hellblau) / 5(dunkelblau) / 6(violett) / 8(weiss) / 40(orange)) string sFarbe = "40"; //Verfasser (A2521) string sVerfasser = txtVerfasser.Text; //Erstellungsdatum (A2524) string sErstellungsdatum = DateTimeToUnixTimestamp(dTPErstellungsdatum.Value).ToString(); // DateTime Wert nach Unix Timestamp Format wandeln //Kommentartext (A511) string sKommentartext = txtKommentartext.Text; if (sKommentartext.EndsWith(Environment.NewLine)) //Kommentar darf nicht mit Zeilenumbruch enden { sKommentartext = sKommentartext.Substring(0, sKommentartext.Length - 2); } sKommentartext = sKommentartext.Replace(Environment.NewLine, " "); //Kommentar Zeilenumbruch umwandeln sKommentartext = "??_??@" + sKommentartext; //Kommentar MultiLanguage String if (!sKommentartext.EndsWith(";")) //Kommentar muss mit ";" enden { sKommentartext += ";"; } //Status, (A2527 = 0(kein Status) / 1(Akzeptiert) / 2(Abgelehnt) / 3(Abgebrochen) / 4(Beendet)) string sStatus = cBStatus.SelectedIndex.ToString(); //Pfad und Dateiname der Temp.datei string sTempFile; #if DEBUG sTempFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\tmpInsertComment.ema"; #else sTempFile = PathMap.SubstitutePath(@"$(TMP)") + @"\tmpInsertComment.ema"; #endif XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter writer = XmlWriter.Create(sTempFile, settings); //Makrodatei Inhalt writer.WriteRaw("\n<EplanPxfRoot Name=\"#Kommentar\" Type=\"WindowMacro\" Version=\"2.2.6360\" PxfVersion=\"1.23\" SchemaVersion=\"1.7.6360\" Source=\"\" SourceProject=\"\" Description=\"\" ConfigurationFlags=\"0\" NumMainObjects=\"0\" NumProjectSteps=\"0\" NumMDSteps=\"0\" Custompagescaleused=\"true\" StreamSchema=\"EBitmap,BaseTypes,2,1,2;EPosition3D,BaseTypes,0,3,2;ERay3D,BaseTypes,0,4,2;EStreamableVector,BaseTypes,0,5,2;DMNCDataSet,TrDMProject,1,20,2;DMNCDataSetVector,TrDMProject,1,21,2;DMPlaceHolderRuleData,TrDMProject,0,22,2;Arc3d@W3D,W3dBaseGeometry,0,36,2;Box3d@W3D,W3dBaseGeometry,0,37,2;Circle3d@W3D,W3dBaseGeometry,0,38,2;Color@W3D,W3dBaseGeometry,0,39,2;ContourPlane3d@W3D,W3dBaseGeometry,0,40,2;CTexture@W3D,W3dBaseGeometry,0,41,2;CTextureMap@W3D,W3dBaseGeometry,0,42,2;Line3d@W3D,W3dBaseGeometry,0,43,2;Linetype@W3D,W3dBaseGeometry,0,44,2;Material@W3D,W3dBaseGeometry,3,45,2;Path3d@W3D,W3dBaseGeometry,0,46,2;Mesh3dX@W3D,W3dMeshModeller,2,47,2;MeshBox@W3D,W3dMeshModeller,5,48,2;MeshMate@W3D,W3dMeshModeller,7,49,2;MeshMateFace@W3D,W3dMeshModeller,1,50,2;MeshMateGrid@W3D,W3dMeshModeller,8,51,2;MeshMateGridLine@W3D,W3dMeshModeller,1,52,2;MeshMateLine@W3D,W3dMeshModeller,1,53,2;MeshText3dX@W3D,W3dMeshModeller,0,55,2;BaseTextLine@W3D,W3dMeshModeller,2,56,2;Mesh3d@W3D,W3dMeshModeller,8,57,2;MeshEdge3d@W3D,W3dMeshModeller,0,58,2;MeshFace3d@W3D,W3dMeshModeller,2,59,2;MeshPoint3d@W3D,W3dMeshModeller,1,60,2;MeshPolygon3d@W3D,W3dMeshModeller,1,61,2;MeshSimpleTextureTriangle3d@W3D,W3dMeshModeller,2,62,2;MeshSimpleTriangle3d@W3D,W3dMeshModeller,1,63,2;MeshTriangle3d@W3D,W3dMeshModeller,2,64,2;MeshTriangleFace3d@W3D,W3dMeshModeller,0,65,2;MeshTriangleFaceEdge3D@W3D,W3dMeshModeller,0,66,2\">"); writer.WriteRaw("\n <MacroVariant MacroFuncType=\"1\" VariantId=\"0\" ReferencePoint=\"64/248/0\" Version=\"2.2.6360\" PxfVersion=\"1.23\" SchemaVersion=\"1.7.6360\" Source=\"\" SourceProject=\"\" Description=\"\" ConfigurationFlags=\"0\" DocumentType=\"1\" Customgost=\"0\">"); writer.WriteRaw("\n <O4 Build=\"6360\" A1=\"4/18\" A3=\"0\" A13=\"0\" A14=\"0\" A47=\"1\" A48=\"1362057551\" A50=\"1\" A59=\"1\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A431=\"1\" A1101=\"17\" A1102=\"\" A1103=\"\">"); //wenn gruppiert sein soll if (chkKommentartextGruppieren.Checked == true) { writer.WriteRaw("\n <O26 Build=\"6360\" A1=\"26/128740\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A431=\"1\">"); } //Eigenschaften Kommentar writer.WriteRaw("\n <O165 Build=\"6360\" A1=\"165/128741\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"" + sEbene + "\" A412=\"" + sLinientyp + "\" A413=\"" + sFarbe + "\" A414=\"0.352777238812552\" A415=\"" + sMusterlänge + "\" A416=\"0\" A501=\"64/248\" A503=\"0\" A504=\"0\" A506=\"22\" A511=\"" + sKommentartext + "\" A2521=\"" + sVerfasser + "\" A2522=\"\" A2523=\"\" A2524=\"" + sErstellungsdatum + "\" A2525=\"" + sErstellungsdatum + "\" A2526=\"2\" A2527=\"" + sStatus + "\" A2528=\"0\" A2529=\"0\" A2531=\"0\" A2532=\"0\" A2533=\"64/248;70.349110320284/254.349110320285\" A2534=\"2\" A2539=\"0\" A2540=\"0\">"); writer.WriteRaw("\n <S54x505 A961=\"L\" A962=\"L\" A963=\"0\" A964=\"L\" A965=\"0\" A966=\"0\" A967=\"0\" A968=\"0\" A969=\"0\" A4000=\"L\" A4001=\"L\" A4013=\"0\"/>"); writer.WriteRaw("\n </O165>"); //Eigenschaften Text writer.WriteRaw("\n <O30 Build=\"6360\" A1=\"30/128742\" A3=\"0\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"" + sEbene + "\" A412=\"L\" A413=\"L\" A414=\"L\" A415=\"L\" A416=\"0\" A501=\"72/248\" A503=\"0\" A504=\"0\" A506=\"0\" A511=\"" + sKommentartext + "\">"); writer.WriteRaw("\n <S54x505 A961=\"L\" A962=\"L\" A963=\"0\" A964=\"L\" A965=\"0\" A966=\"0\" A967=\"0\" A968=\"0\" A969=\"0\" A4000=\"L\" A4001=\"L\" A4013=\"0\"/>"); writer.WriteRaw("\n </O30>"); //wenn gruppiert sein soll if (chkKommentartextGruppieren.Checked == true) { writer.WriteRaw("\n </O26>"); } writer.WriteRaw("\n <O37 Build=\"6360\" A1=\"37/128743\" A3=\"1\" A13=\"0\" A14=\"0\" A404=\"1\" A405=\"64\" A406=\"0\" A407=\"0\" A682=\"1\" A683=\"26/128740\" A684=\"0\" A687=\"8\" A688=\"2\" A689=\"-1\" A690=\"-1\" A691=\"0\" A693=\"1\" A792=\"0\" A793=\"0\" A794=\"0\" A1261=\"0\" A1262=\"44\" A1263=\"0\" A1631=\"0/-6.34911032028501\" A1632=\"8/0\">"); writer.WriteRaw("\n <S109x692 Build=\"6360\" A3=\"0\" A13=\"0\" A14=\"0\" R1906=\"165/128741\"/>"); writer.WriteRaw("\n <S109x692 Build=\"6360\" A3=\"0\" A13=\"0\" A14=\"0\" R1906=\"30/128742\"/>"); writer.WriteRaw("\n <S40x1201 A762=\"64/254.349110320285\">"); writer.WriteRaw("\n <S39x761 A751=\"1\" A752=\"0\" A753=\"0\" A754=\"1\"/>"); writer.WriteRaw("\n </S40x1201>"); writer.WriteRaw("\n <S89x5 Build=\"6360\" A3=\"0\" A4=\"1\" R7=\"37/128743\" A13=\"0\" A14=\"0\" A404=\"9\" A405=\"64\" A406=\"0\" A407=\"0\" A411=\"308\" A412=\"L\" A413=\"L\" A414=\"L\" A415=\"L\" A416=\"0\" A1651=\"0/-6.34911032028501\" A1652=\"8/0\" A1653=\"0\" A1654=\"0\" A1655=\"0\" A1656=\"0\" A1657=\"0\"/>"); writer.WriteRaw("\n </O37>"); writer.WriteRaw("\n </O4>"); writer.WriteRaw("\n </MacroVariant>"); writer.WriteRaw("\n</EplanPxfRoot>"); // Write the XML to file and close the writer. writer.Flush(); writer.Close(); //Makro einfügen #if DEBUG MessageBox.Show(sTempFile); #else CommandLineInterpreter oCli = new CommandLineInterpreter(); ActionCallingContext oAcc = new ActionCallingContext(); oAcc.AddParameter("Name", "XMIaInsertMacro"); oAcc.AddParameter("filename", sTempFile); oAcc.AddParameter("variant", "0"); oCli.Execute("XGedStartInteractionAction", oAcc); #endif //Beenden Close(); return; }
public bool Execute(ActionCallingContext oActionCallingContext) { Preview.MainWindow mainWindow = new Preview.MainWindow(); mainWindow.ShowDialog(); return(true); }