| |
 | Gut zu wissen: Hilfreiche Tipps und Tricks aus der Praxis prägnant, und auf den Punkt gebracht für EPLAN |
| |
 | Automatische Schaltplanerstellung in der Cloud, eine Pressemitteilung
|
Autor
|
Thema: Using XEsSetPagePropertyAction (3141 / mal gelesen)
|
blitzkreig Mitglied Engineer

 Beiträge: 20 Registriert: 03.09.2018
|
erstellt am: 15. Okt. 2018 12:55 <-- editieren / zitieren --> Unities abgeben:         
Hi, I'm trying write a script which opens a project and performs XEsSetPagePropertyAction and sets a value to Creator, Revision date and revision of the project. The script I have runs fine if I open project, then run it from Utilities > Run. But if I run it from command line, it does not work. The opening project part works, but not XEsSetPagePropertyAction. However it works if I run it after opening the project manually. Here is my code: Code: [Start] public void Action() { CommandLineInterpreter oCli = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("Project", "D:\\project\\test.elk"); oCli.Execute("ProjectOpen", acc); CommandLineInterpreter oCLI2 = new CommandLineInterpreter(); ActionCallingContext acc2 = new ActionCallingContext(); acc2.AddParameter("PropertyIdentName", "EPLAN.Page.UserSupplementaryField4"); acc2.AddParameter("PropertyIndex", "0"); acc2.AddParameter("PropertyValue", "Test Creator"); oCLI2.Execute("XEsSetPagePropertyAction", acc2); }
Any help is appreciated! Thanks! Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
F.S. Moderator
    
 Beiträge: 1924 Registriert: 23.04.2003 EPLAN Electric P8 2025 Prof.
|
erstellt am: 15. Okt. 2018 13:47 <-- editieren / zitieren --> Unities abgeben:          Nur für blitzkreig
|
blitzkreig Mitglied Engineer

 Beiträge: 20 Registriert: 03.09.2018
|
erstellt am: 15. Okt. 2018 13:48 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von F.S.: Hi,I miss the disclosure in which page the properties are to be set?
Hi, Sorry for not being clear, I want the page property to be changed for all pages in the project. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
blitzkreig Mitglied Engineer

 Beiträge: 20 Registriert: 03.09.2018
|
erstellt am: 17. Okt. 2018 11:43 <-- editieren / zitieren --> Unities abgeben:         
|
Jonny Wire Mitglied Script-Troll
  
 Beiträge: 811 Registriert: 08.12.2008 EPLAN Electric P8 ... in allen Versionen/Varianten
|
erstellt am: 17. Okt. 2018 15:01 <-- editieren / zitieren --> Unities abgeben:          Nur für blitzkreig
|
blitzkreig Mitglied Engineer

 Beiträge: 20 Registriert: 03.09.2018
|
erstellt am: 30. Okt. 2018 07:13 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von Jonny Wire: You have to do that for each page. See here for an example: https://suplanus.de/selectionset-pages/Replace the code in SelectPage().
I tried it, but it's still not changing the property for some reason. Here is my code: Code: using Eplan.EplApi.ApplicationFramework; using Eplan.EplApi.Scripting; public class Script { [Start] public void Action() { CommandLineInterpreter oCli = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("Project", @"D:\project\FEX.elk"); oCli.Execute("ProjectOpen", acc); var pages = GetPages(); try { // Do something with pages foreach (var page in pages) { SelectPage(page); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private static string[] GetPages() { ActionCallingContext actionCallingContext = new ActionCallingContext(); string pagesString = string.Empty; actionCallingContext.AddParameter("TYPE", "PAGES"); new CommandLineInterpreter().Execute("selectionset", actionCallingContext); actionCallingContext.GetParameter("PAGES", ref pagesString); string[] pages = pagesString.Split(';'); return pages; } private void SelectPage(string page) { CommandLineInterpreter oCLI2 = new CommandLineInterpreter(); ActionCallingContext acc2 = new ActionCallingContext(); acc2.AddParameter("PropertyIdentName", "EPLAN.Page.UserSupplementaryField4"); acc2.AddParameter("PropertyIndex", "0"); acc2.AddParameter("PAGENAME", page); acc2.AddParameter("PropertyValue", "2"); var result = oCLI2.Execute("XEsSetPagePropertyAction", acc2); } }
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
F.S. Moderator
    
 Beiträge: 1924 Registriert: 23.04.2003 EPLAN Electric P8 2025 Prof.
|
erstellt am: 30. Okt. 2018 09:51 <-- editieren / zitieren --> Unities abgeben:          Nur für blitzkreig
I think , Jonny mean it in this way Code:
using Eplan.EplApi.ApplicationFramework; using Eplan.EplApi.Scripting; public class Script { [Start] public void Action() { CommandLineInterpreter oCli = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("Project", @"D:\project\FEX.elk"); oCli.Execute("ProjectOpen", acc); var pages = GetPages(); try { // Do something with pages foreach (var page in pages) { SelectPage(page); CommandLineInterpreter oCLI2 = new CommandLineInterpreter(); ActionCallingContext acc2 = new ActionCallingContext(); acc2.AddParameter("PropertyIdentName", "EPLAN.Page.UserSupplementaryField4"); acc2.AddParameter("PropertyIndex", "0"); acc2.AddParameter("PropertyValue", "2"); var result = oCLI2.Execute("XEsSetPagePropertyAction", acc2); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private static string[] GetPages() { ActionCallingContext actionCallingContext = new ActionCallingContext(); string pagesString = string.Empty; actionCallingContext.AddParameter("TYPE", "PAGES"); new CommandLineInterpreter().Execute("selectionset", actionCallingContext); actionCallingContext.GetParameter("PAGES", ref pagesString); string[] pages = pagesString.Split(';'); return pages; } private void SelectPage(string page) { ActionCallingContext actionCallingContext = new ActionCallingContext(); actionCallingContext.AddParameter("PAGENAME", page); new CommandLineInterpreter().Execute("edit", actionCallingContext); } }
------------------ grüße FrankS Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
blitzkreig Mitglied Engineer

 Beiträge: 20 Registriert: 03.09.2018
|
erstellt am: 31. Okt. 2018 06:53 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von F.S.: I think , Jonny mean it in this way
Thanks for the response. I tried your code, but it tries to open the project multiple times, so I get the error 'Project is already open'. Also, the property is not changing for some reason.  Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |

| Teamlead (m/w/d) CAD & PLM/PDM Systeme | Wir bei Reifenhäuser arbeiten innerhalb der Firmengruppe und über unsere Unternehmensgrenzen hinaus mit Leidenschaft und Pioniergeist daran, die Kunststoffindustrie in eine nachhaltige Zukunft zu führen. Auf dem Weg haben wir uns vom weltweit führenden Extrusions-Maschinenbauer mit über 100 Jahren Erfahrung zum Lösungsanbieter entwickelt, den vor allem eines antreibt: den Alltag von Vielen besser zu machen ? für die Menschen heute und für kommende Generationen.... | Anzeige ansehen | Feste Anstellung |
|
blitzkreig Mitglied Engineer

 Beiträge: 20 Registriert: 03.09.2018
|
erstellt am: 31. Okt. 2018 08:22 <-- editieren / zitieren --> Unities abgeben:         
I think selectionSet only works with SELECTED changes. So since no pages are selected by default when a project is opened, GetPages() return null. I think this is why it's not working. So how do I select all pages in the project when I open it? [Diese Nachricht wurde von blitzkreig am 31. Okt. 2018 editiert.] Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |