First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

How to "run automation file" through a python instruction (API)?

asked Feb 14 '18

IEQQ02 gravatar image

updated Feb 14 '18

jconto gravatar image
PSSE_PATH = r'C:\Program Files (x86)\PTI\PSSE32\PSSBIN'

sys.path.append(PSSE_PATH)

os.environ['PATH'] += ';' + PSSE_PATH

import psspy

psspy.psseinit(0) 

psspy.case(str(archivo_sav.name))

#Here: "Run Automation File with python API"

psspy.save(os.path.join(Ruta,r"Archivo_prueba.sav"))

psspy.close_powerflow()

2 answers

Sort by » oldest newest most voted
0

answered Feb 14 '18

perolofl gravatar image

Use execfile to execute a Python script inside a script, e.g. execfile(”xxx.py”)

link

Comments

Thank you very much!!

IEQQ02 gravatar imageIEQQ02 (Feb 14 '18)
0

answered Feb 14 '18

jconto gravatar image

The variable 'archivo_sav.name', 'Ruta' are not defined, add something like:

archivo_sav_name = 'savnw.sav'
Ruta = 'c:\temp'

To run a python script: From the PSSe GUI, select the play icon, then set file type as *.py and select your python code. Functions names (like xx) in the API manuals require to be called with "psspy.xx" in your code.

link

Comments

Okay, but I want to know if it's possible to call or execute a python code without clicking on the icon. Do it using a "psspy." command

IEQQ02 gravatar imageIEQQ02 (Feb 14 '18)

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

2 followers

Stats

Asked: Feb 14 '18

Seen: 913 times

Last updated: Feb 14 '18