Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Abaqus Macro (.py) script

Tags:

macros

abaqus

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

like image 729
Olu adroit Avatar asked Oct 30 '25 05:10

Olu adroit


2 Answers

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.

like image 189
agentp Avatar answered Nov 01 '25 12:11

agentp


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.

like image 44
hgazibara Avatar answered Nov 01 '25 12:11

hgazibara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!