Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I pass command-line arguments to Abaqus python?

Tags:

python

I have an abaqus python script I've been using for a parametric study. It is exhausting to go into the code and edit it every time I want to run different options. I'd like to be able to pass the script arguments so that I can run different options without needing to change the code.

I'd like to do something like this...

abaqus cae script='Script.py --verbose --data=someData.dat'

I've tried the above and I've also tried

abaqus python Script.py --verbose --data=someData.dat

With no success. Is this at all possible?

like image 341
grasingerm Avatar asked Mar 30 '14 21:03

grasingerm


1 Answers

Good find Schickmeister. It was not clear to me how to implement, so here is an example

launch abaqus python in cmd.exe

abaqus cae noGUI

enter some python code

>>>import sys
>>>print sys.argv
['C:\\ABAQUS\\6.13-2SE\\code\\bin\\ABQcaeK.exe', '-cae', '-noGUI', '-lmlog',     'ON', '-tmpdir', 'C:\\Windows\\TEMP']
>>>quit()

See how many arguments show up? That's why we need to grab the last one now launch your python script with argument "test.odb"

abaqus cae noGUI=odb_to_video.py -- test.odb

and retrieve the last argument in your script with

odbname = sys.argv[-1]
myOdb = visualization.openOdb(path=odbname)

hope this helps!

like image 167
nagordon Avatar answered Sep 19 '22 09:09

nagordon