How to run Abaqus Macro (.py) script

◇◆丶佛笑我妖孽 提交于 2019-12-06 09:29:44

to run a python script that relies on abaqus cae from the command line and without opening up the gui window you do:

 abaqus cae noGUI=script.py

As mentioned if all the script does is define a macro, well that's all it does is define the macro and quit. Typically you need to add code to open an odb, do something, write output, etc.

In general, Python scripts can be run in Abaqus via 'File > Run script'. However, as is a case for all Python scripts, if all your code is contained inside of a function (and in case of Abaqus macro, it is), and that function is never called explicitly inside the script, the code will not be executed.

You file probably looks something like this:

from abaqus import *
# some other imports, if any

def macro_function():
    # code defining the macro's behavior

You should edit the script by calling the function at the end of the script.

If you want some more concrete help, post your actual code.

EDIT: To call the defined function, you just write macro_function() at the end of the file, so that the script looks something like this:

from abaqus import *
# some other imports, if any

def macro_function():
    # code defining the macro's behavior

macro_function()

Maybe it would be easier if you just had the code outside of the function and remove the function completely. For anything more than this, you really should learn some Python.

According to my moderate experience, if you need loop computations, you have to launch the script inside CAE, since when starting it in command line, only one cycle is computed. An example of the script intended for loop computations and visualisation, you can find at researchgate, search text "How to write scripts for Abaqus"

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!