Olu adroit
Olu adroit

Reputation: 41

How to run Abaqus Macro (.py) script

I am new to python. I generated a macro which is a .py script using Abaqus Macro manager. I realised that this script works only when run from the Abaqus manager and does not run by itself. Please does anyone know how to modify this script so i can run it without using the Abaqus. Thank you in advance for your help

Adroit

Upvotes: 4

Views: 31393

Answers (3)

Sergey Kuznetsov
Sergey Kuznetsov

Reputation: 11

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"

Upvotes: 1

hgazibara
hgazibara

Reputation: 1832

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.

Upvotes: 2

agentp
agentp

Reputation: 6989

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.

Upvotes: 4

Related Questions