Executing Python scripts via Elipse E3.

Python is a general-purpose programming language especially used for scientific and engineering solutions due to its several libraries for handling data, calculations, statistics, visualization, etc.

Elipse E3 has no native support to this language; however, external applications can be executed via VBScript, with a command similar to Window’s Execute. For these purpose, you need to download the interpreter and the libraries used by the script. For further information, check out Instalação do Python para uso integrado ao EPM (in Portuguese).

Example 1:  Python code generating a bar chart with Matplotlib library, using the data received via command line arguments.

import sys
import numpy as np
import matplotlib.pyplot as plt

rs = sys.argv[1]
rj = sys.argv[2]
pr = sys.argv[3]
sp = sys.argv[4]
mg = sys.argv[5]

estados = (‘RS’, ‘RJ’, ‘PR’, ‘SP’, ‘MG’)
y_pos = np.arange(len(estados))
performance = [rs,rj,pr,sp,mg]

plt.barh(y_pos, performance, align=‘center’, alpha=0.4)
plt.yticks(y_pos, estados)
plt.xlabel(‘Temp’)
plt.title(‘Elipse E3’)
plt.show()

Example 2:  VBScript code passing arguments and executing the program in Python.

temprs = Screen.Item(“spTempRS”).Value
temprj = Screen.Item(“spTempRJ”).Value
temppr = Screen.Item(“spTempRS”).Value
tempsp = Screen.Item(“spTempSP”).Value
tempmg = Screen.Item(“spTempMG”).Value

Dim oShell
Set oShell = CreateObject(“WSCript.shell”)
oShell.run “grafico.py “&temprs&” “&temprj&” “&temppr&” “&tempsp&” “&tempmg,0

The result is a pop-up window similar to the one below:

Attached to this article is an application employing this example, with annotated code.

 

Attachments:

E3Python.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *