Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: ArshiaZare on June 06, 2023, 07:06:16 pm

Title: How should I run a python script, directly on EA with the help of javascript?
Post by: ArshiaZare on June 06, 2023, 07:06:16 pm
Hello all,

I have a python code that needs to run on EA, (the code works outside EA and all is fine) I thought maybe using Javascript in scripting tool that EA provides is the answer, as it's been awhile since I have used JavaScript (without HTML for that matter) any code templates I can use?

thank you
Title: Re: How should I run a python script, directly on EA with the help of javascript?
Post by: qwerty on June 06, 2023, 08:20:23 pm
Python will run entirely outside EA. Use Win32 to either create an EA instance or to connect to a running one (I usually use the latter).

q.
Title: Re: How should I run a python script, directly on EA with the help of javascript?
Post by: ArshiaZare on June 06, 2023, 09:51:59 pm
Python will run entirely outside EA. Use Win32 to either create an EA instance or to connect to a running one (I usually use the latter).

q.

thank you for your reply, yes my python code uses win32 and runs the needed functions all fine, I wanted to know if there is a way to have this added as a script in EA so the members of my team can also add it in there so there is no need to run it outside for convinience, my idea was to use javascript to access the python code, if there is nothing notable i can do (nothing thats not too much of a hassle) then i geuss I'll continue running it outside, no problem  :)
Title: Re: How should I run a python script, directly on EA with the help of javascript?
Post by: Geert Bellekens on June 06, 2023, 11:12:33 pm
should be possible using shell.run or something like that.

Here a reference to a solution using VBScript, but usually you can achieve the same thing using javascript

https://stackoverflow.com/questions/6732543/running-python-script-using-wshshell-run-in-vbs-does-not-generate-output-file (https://stackoverflow.com/questions/6732543/running-python-script-using-wshshell-run-in-vbs-does-not-generate-output-file)

Geert
Title: Re: How should I run a python script, directly on EA with the help of javascript?
Post by: qwerty on June 07, 2023, 12:51:45 am
I had an add-in to run Python. Was fairly easy to code (basically stating from Geert's 10 minute tutorial).

q.