简体   繁体   中英

How to run ABAQUS python script from Visual Studio Code?

I am trying to use Visual Code Studio for editing and running Python scripts for ABAQUS (finite element software using internal Python 2.7 interpreter with a lot of libraries).

The standard situation is that I run this command from Windows cmd prompt

abaqus cae noGUI="myscript.py"

==========================================================

EXPLANATION:

The command "abaqus" is a reference to this batch file

C:\SIMULIA\Commands\abaqus.bat

containing

@echo off
"C:\SIMULIA\Commands\abq2018.bat" %*

and the latter batch file abq2018.bat contains this

@echo off
setlocal
set ABA_COMMAND=%~nx0
set ABA_COMMAND_FULL=%~f0
"C:\SIMULIA\CAE\2018\win_b64\code\bin\ABQLauncher.exe" %*
endlocal

This is a standard configuration used for ABAQUS software.

==========================================================

Normally, I edit the Python scripts in PSPad and hit F9 which runs the edited script using the macro (therein called Highlighter)

"c:\SIMULIA\Commands\abaqus.bat" cae nogui="%File%"

and everything is perfect.

I tried to set up a similar "one click to run" scenario in Visual Studio Code by playing with "Workspace", "Interpreter", "launch.json" and "python.pythonPath" settings but without any success. The default Python interpreter 3.7 works normally for standard Hello-world etc. scripts.

My goal is to use the debugging features in Visual Studio Code...

Thanks for any help Robert

Although the question is asked almost two years ago, if somebody is looking to use Visual Code Studio for editing and running Python scripts for ABAQUS, see pyabaqus.

Documentation:
https://pyabaqus.haiiliin.com/

Yes, I use it with VS Code and I am able to run it direcly from VSC. I have python 3.11 and installed pyabaqus package. You don't tell VSC the location of abaqus instead you add the.bat file to path. The Pyabaqus finds the location of Abaqus. This package is not specific to VSC and python interpreter should work. I didn't see any type hints tough.

From pyabaqus doc:

“ Setup your Abaqus Environment In order to use Abaqus command to execute the Python script and submit the job, you need to tell pyabaqus where the Abaqus command is located. Usually, Abaqus command locates in a directory like this:

C:/SIMULIA/Commands/abaqus.bat You can add the directory C:/SIMULIA/Commands to the system environment variable Path, or you can create a new system variable named ABAQUS_BAT_PATH, and set the value to the file path of the Abaqus command, ie, C:/SIMULIA/Commands/abaqus.bat.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM