Imagine you need to run the same Abaqus analysis 50 times with small changes. Doing that by hand could take hours or even days. With Abaqus Scripting, it can take minutes.
Abaqus Python scripts let you tell Abaqus what to do step by step.
You can automate model creation, run parametric studies, and process results — all without endless clicking.
It’s like teaching Abaqus your routine, so it works while you grab coffee.
In this guide, we’ll start from zero. You’ll learn the basics of Python you actually need, understand how Abaqus and Python connect, and explore the key files that make scripting possible. Then, we’ll move step-by-step into reading, modifying, and running your own scripts — even if you’ve never written code before.
By the end, you’ll not only know what Abaqus scripting is, but also how to use it to make your projects faster, smarter, and more efficient. Whether you want to automate geometry creation, adjust parameters on the fly, or build custom tools, this tutorial will give you the foundation to make it happen.
Lesson 1: Why Abaqus Scripting Matters?
Abaqus is powerful.
But clicking through menus for repetitive work wastes time.
First, let’s answer this question:
“What do we mean when we say Abaqus scripting?”
Scripting means writing commands and instructions in a scripting language — like Python — to extend, speed up, or automate the features of a software.
So when we say Abaqus Scripting, we mean automating tasks, customizing workflows, and extending the functionality of Abaqus.
In short: you tell Abaqus exactly what to do, and it follows your instructions without missing a step.
Abaqus Python gives you that control.
You can write a small script once and run it many times.
Need to create 100 variations of a part? A script can do that while you focus on design.
Think of it like a recipe.
Once the steps are written, Abaqus can repeat them perfectly — no typos, no skipped clicks.
What can you automate?
- Creating geometry and assemblies.
- Setting up loads and boundary conditions.
- Running analyses with different parameters.
- Extracting and plotting results.
- Preparing files for 3D printing.
- Creating custom plug-ins inside Abaqus to speed up routine tasks.
- Automating complex micromechanics models (like simulating hundreds of fibres).
- Processing large result sets for data analysis.
While Python scripting lets you automate and customize many aspects of simulation, some advanced requirements—such as custom material models, element formulations, or deeper solver control—are best addressed through an Abaqus subroutine. If you want to learn how to start writing Abaqus subroutines and extend your simulation capabilities even further, check out our step-by-step guide on Abaqus subroutine development.
Your first exercise
We’re not going to start with a big project.
Instead, let’s create a tiny script that makes a 10 × 10 × 10 mm cube in Abaqus.
# myblock.py
from abaqus import mdb
from abaqusConstants import *
# Create a new model
model = mdb.Model(name=’CubeModel’)
# Create a sketch
s = model.ConstrainedSketch(name=’cube_sketch’, sheetSize=50.0)
s.rectangle(point1=(0.0, 0.0), point2=(10.0, 10.0))
# Create the part
p = model.Part(name=’Cube’, dimensionality=THREE_D, type=DEFORMABLE_BODY)
p.BaseSolidExtrude(sketch=s, depth=10.0)
print(“Cube created successfully!”)
To run it:
- Save this code as py.
- In Abaqus/CAE, go to File → Run Script and select py.
- The cube appears in your model tree.
This small step shows you how Abaqus Python turns a few lines of code into a finished model — no manual clicking needed.
Lesson 2: Python Basics for Abaqus Scripting
Before we dive into Abaqus Python, we need a small toolkit of Python skills. Think of these as the alphabet you’ll use to “talk” to Abaqus.
You don’t have to master the whole language.
Just enough to start scripting in Abaqus.
In Python, data types are a core concept.
They decide what kind of information you can store in a variable and what you can do with it.
For example, numbers can be added, text can be joined, and lists can be looped over.
Python comes with built-in data types, each with its own purpose. You can see them in one glance in the table below:
| Type | Categories | Class | Description |
| Numeric | Integer, float, complex | int, float, complex | Holds numeric values |
| Sequence | list, tuple, range, string | list, tuple, range, str | Holds collection of items |
| Binary | Bytes, Bytearray, Memoryview | bytes, bytearray, memoryview | Represents sequences of binary data |
| Mapping | Dictionary | dict | Holds data in key-value pair form |
| Boolean | Boolean | bool | Holds either True or False |
| Set | Set, Frozen set | set, frozenset | Collection of unique elements |
Numeric Data Type
Numeric data type represents the numeric values in Python and they are categorized in three categories: Integer, float, and complex.
This is a whole number data type that can be positive, negative or zero. In Python, integers are represented by the “int” class. Here an example of integer values:
# Integer
x = 5
y = -10
z = 0
Complex
A complex number is a number that has both a real and an imaginary component. This data type represents complex numbers. The “complex” class in Python is used to represent complex numbers. Here is an example:
# Complex
d = 2 + 3j
e = -4j
f = 0 + 1j
Float
This is a decimal number data type that can be positive, negative or zero. In Python, floating-point numbers are represented by the float class. Here is an example:
# Float
a = 3.14
b = -2.5
c = 0.0
Mathematical Operations On Numeric Data
On variables with various numeric data types in Python, you may also apply mathematical operations. The most “complex” data type will be used to automatically convert the outcome. For instance:
# Integer and float
result = 5 + 2.5
print(result)
# Float and complex
result = 3.14 + (-2.5j)
print(result)
# Integer and complex
result = 5 + 3j
print(result)
Sequence Data Types
In Python, a sequence is a data type that represents an ordered collection of items; in other words, sequence data types are used in the Python programming language to store data in containers. List, Tuple, String, and Range are some of the different types of containers that are utilized to hold the data.
# List
my_list = [1, 2, “three”, 4.0, True]
Each item is assigned a unique index starting from 0 “[a0, a1, …, an-1]”. We can access each element of the list. The following example demonstrates how to generate a list and retrieve its elements using index notation. We used both positive and negative indexing methods. Negative indexing starts counting from the end, where -1 refers to the final item, -2 refers to the second-to-last item, and so on.
my_list = [1, 2, “three”, 4.0, “True”, “best”, “good”]
print(my_list[0])
print(my_list[3])
print(my_list[-2])
print(my_list[-1])
print(my_list[0:2]) # elements in [0, 2)
Several operations can be carried out on the list, including but not limited to append, remove, insert, extend, reverse, sorted, and more. These operations can be modified and executed as needed. For example:
my_list = [1, 2, “three”, 4.0, “True”, “best”, “good”]
my_list.append(3) # insert at the end of the list
print(my_list)
# Another example:
my_list = [1, 2, “three”, 4.0, “True”, “best”, “good”]
my_list.reverse() # reverse the order
print(my_list)
String
Strings are used to represent text data in Python. They are written within single quotes (‘…’) or double quotes (“…”) and can contain any combination of letters, digits, and special characters. Note that spaces are significant.
Also, you can perform various operations on the string data.
str1 = “Hello”
str2 = “World”
result = str1 + ” ” + str2
print(result)
str = “Hello World”
result = str.upper()
print(result)
result = str.lower()
print(result)
Tuple
Unlike lists, tuples are immutable, thus once they are generated, their contents cannot be altered. Each item is separated by a comma and written within parentheses “()”.
# Tuple
my_tuple = (10, 20, 30, “forty”, 50.0)
Range
A series of numbers is represented using the range data type in Python. It is a form of immutable sequence that creates numbers instantly without storing them in memory. It creates the numbers instead as they are required, which is efficient when dealing with lengthy sequences. The range type takes three arguments: start, stop, and step. The start argument specifies the starting value of the sequence (inclusive), the stop argument specifies the ending value of the sequence (exclusive), and the step argument specifies the difference between each number in the sequence. See the example below:
print(list(range(10)))
print(list(range(2, 20, 4)))
Mapping Data Type
A mapping data type in Python is a way of storing information as key–value pairs, where each key is unique and used to access its corresponding value. The most common example is the dictionary (dict), which works like a real dictionary: you look up a word (the key) and find its meaning (the value).
Keys are usually strings or numbers, and values can be anything—numbers, strings, lists, or even other dictionaries. In Python 3.7+, dictionaries remember the order in which items are added, but the main magic is still about quick lookups using keys.
Basic things to know
- Keys must be unique: If you add the same key again, the old value is replaced.
- Keys must be hashable: You can use strings, numbers, or tuples, but not lists or other dictionaries.
- Values can be any type: No restrictions here.
- Mutable: You can add, change, or remove items after creating the dictionary.
The table below shows you the common operations you can apply on this type of data:
| Operation | Description0 | Python Example |
| Access value by key | Retrieve a value using its key | numbers[‘one’] |
| Add or update item | Insert a new key–value pair or change existing value | numbers[‘four’] = 4 |
| Check if key exists | Test whether a key is in the dictionary | ‘two’ in numbers |
| Remove item by key | Delete a key–value pair | del numbers[‘two’] |
| Remove and return value | Delete a key and get its value | numbers.pop(‘three’) |
| Get all keys | Return all dictionary keys | numbers.keys() |
| Get all values | Return all dictionary values | numbers.values() |
| Get all items | Return all key–value pairs | numbers.items() |
| Clear dictionary | Remove all items from the dictionary | numbers.clear() |
# Creating a dictionary
numbers = {‘one’: 1, ‘two’: 2, ‘three’: 3}
print(“Original dictionary:”, numbers)
# 1. Access value by key
print(“Value for ‘one’:”, numbers[‘one’])
# 2. Add or update item
numbers[‘four’] = 4 # Add new key–value pair
numbers[‘one’] = 11 # Update existing value
print(“After adding/updating:”, numbers)
# 3. Check if key exists
if ‘two’ in numbers:
print(“‘two’ exists in the dictionary”)
# 4. Remove item by key
del numbers[‘two’]
print(“After deleting ‘two’:”, numbers)
# 5. Remove and return value
removed_value = numbers.pop(‘three’)
print(“Removed value for ‘three’:”, removed_value)
print(“After popping ‘three’:”, numbers)
# 6. Get all keys, values, and items
print(“Keys:”, numbers.keys())
print(“Values:”, numbers.values())
print(“Items:”, numbers.items())
# 7. Clear dictionary
numbers.clear()
print(“After clearing:”, numbers)
Boolean Data Type
In Python, the boolean data type is a built-in data type that represents the truth values True and False. Booleans are used in logical expressions and conditional statements to represent the truth or falsity of a condition. You can see some examples below:
# Boolean Data Type Examples
# Equality check
print(5 == 3 + 2) # Expected output: True
# Inequality check
print(5 != 3 * 2) # Expected output: False
# Greater-than check
print(5 > 3 * 2) # Expected output: False
# Logical OR combining two comparisons
print(5 > 3 * 2 or 5 < 3 * 2) # Expected output: False
Sets Data Type
In Python, the set data type is a built-in data type that represents a collection of unique elements. Sets are unordered and mutable, which means that you can add or remove elements from a set, but you cannot access them by index.
Here’s an example of using sets in Python:
# Define a set
my_set = {1, 2, 3, 4, 5}
# Print the set
print(my_set)
# Add an element to the set
my_set.add(6)
# Print the set again
print(my_set)
# Remove an element from the set
my_set.remove(3)
# Print the set again
print(my_set)
Also, you can perform some operations on set data:
# Define two sets
set1 = {1, 2, 3, 4, 5}
set2 = {4, 5, 6, 7, 8}
# Use set operations
union_set = set1.union(set2)
print(union_set)
intersection_set = set1.intersection(set2)
print(intersection_set)
difference_set = set1.difference(set2)
print(difference_set)
Indentation
In Python, indentation matters.
It’s not just for looks — it tells Python which lines belong together.
If the spaces are wrong, the script won’t run.
Bad indentation is like skipping a step in a recipe.
The dish (or the script) fails.
Now, you know the basics of the Python you needed to know for Abaqus Scripting. But if you want to learn more and still feels you need more than that for Abaqus scripting such as some functions and loops, you can check out our full tutorial which can help you out in this matter.
Lesson 3: Abaqus Python Terminology and Python’s Role
Before writing your first Abaqus Python script, it helps to know the language Abaqus itself uses.
This is not Python code yet — these are the terms Abaqus uses to describe its own parts, actions, and files.
Think of them as the map you’ll use when scripting.
Terminology
Before we continue, there are several words in Abaqus scripting that needs to be known by whoever wants to do scripting. These words help the user to get to know the Abaqus environment and understand the role of Python and Abaqus Python scripting in the Abaqus analyses.
Graphical User Interface (GUI): GUI or graphical user interface is a graphical environment between the user and the Abaqus CAE kernel. The interface allows users to specify geometry and select options from dialog boxes.
The GUI is an operating system interface that relies on graphical elements such as icons and menus, as well as a mouse to interact with the software. Users can click on the icons or pull down the menus to manage their interactions with the Abaqus, including creating parts, material properties, analysis steps, etc.
Command Line Interface (CLI): It is a text-based interface that allows users to interact with the Abaqus software by typing commands into a command prompt. The command line interface or CLI is hidden by default but it uses the same space occupied by the message area.
The CLI is activated by clicking on the arrow shape button (>>>), as you see in the picture below. Users can type in commands to define and run simulations, view results, and perform other operations.
Script and Script file: A script refers to a set of commands written in a programming language. A script file includes a set of programming codes, commands, or instructions written in a programming language that can be executed by an interpreter or a computer program to run its commands.
Script files in Abaqus have a “.py” extension, indicating that they are written in the Python programming language; they can be written in the Abaqus PDE, Notepad++, or any other text editor software and must be saved with the “.py” extension.
Abaqus Scripting Interface (ASI): ASI, which is abbreviated as Abaqus scripting interface, is a Python-based application programming interface (API) to Abaqus. ASI commands are issued to the Abaqus Python interpreter from either the GUI, the command line interface, or a script.
Application Programming Interface (API): API is a set of routines, protocols, and tools that make developing a software application easier.
Abaqus/CAE kernel: It is the main brain of the Abaqus software. This gets the scripting commands, creates an internal representation of the model, and then saves it as an input file with the extension “.inp”
Abaqus/CAE: Abaqus/CAE is an all-inclusive Abaqus environment that offers a straightforward and consistent interface for generating, submitting, monitoring, and assessing results from Abaqus/Standard and Abaqus/Explicit simulations. The commands in Abaqus/CAE are scripted in Python, and you can utilize Abaqus Python to improve the scripts produced by Abaqus/CAE.
Most activities carried out during an Abaqus/CAE session can be replicated using a script (script_name.py) that includes a series of Abaqus Scripting Interface commands. Similarly, executing a script in Abaqus/CAE is the same as performing the related actions using the various menus, toolboxes, and dialog boxes provided by Abaqus/CAE.
Python role in Abaqus | Abaqus Python scripting
Until now, you have learned what Abaqus Python scripting is, the ways to do the scripting, and some necessary concepts; but how are these concepts going to make sense all together and help us understand the role of Python in Abaqus?
There are three ways to send Python commands to the Python interpreter, including GUI, CLI, and script, which were explained before (see flowchart below). After interpreting commands by the Python interpreter, they are sent to the kernel in order to create an input file. In addition, a replay file containing Python commands is created in case of using GUI.
All these steps, from writing commands to creating an input file, are called Abaqus/CAE (see flowchart below). After creating the input file, it is sent to solvers, Abaqus standard or Abaqus explicit, to solve the problem and then write an output database file.
Related Abaqus Files to Python Scripting
The Abaqus creates several files for each modeling and analysis, such as “.cae“, “.inp“, “.jnl“, “.odb“, etc. In this section, the files related to Python scripting will be introduced.
- “.rpy” (replay) file: Records your GUI actions as Python commands.
- “abaqusMacro.py” file: Abaqus/CAE enables users to automate repetitive tasks by executing Python scripts, but creating such scripts from scratch can be challenging for beginners. To simplify the process of generating scripts, Abaqus/CAE provides a macro recording feature that enables users to record a series of actions and save them as a Python script. When a macro is generated, ABAQUS/CAE captures a series of ABAQUS Scripting Interface commands in a macro file as you interact with the software. Each command corresponds to a specific action within ABAQUS/CAE, and replaying the macro replays the same sequence of actions. The macros are saved in a file named abaqusMacros.py.
- “.inp” (input) file: Text file sent to the solver with all analysis instructions. Learn more.
- “.jnl” (journal) file: In Abaqus, a journal file is a text file that records the sequence of commands and interactions performed by the user in Abaqus/CAE. The journal file is created automatically when the user performs actions in Abaqus/CAE, and it contains a record of the actions taken, including the menus and options chosen, the dialogs opened, and the commands executed. The journal file can be used as a starting point for creating Python scripts that can be executed in Abaqus/CAE. The commands contained in the journal file can be edited and modified to create a customized Python script that automates specific tasks.
- “.py” file: This is the Python script that we write by ourselves, which was explained in the previous sections.
Lesson 4: Your First Abaqus Python Script the Easy Way
Many beginners think they must start scripting in Abaqus from a blank Python file.
That’s like trying to learn to swim in the middle of the ocean.
Instead, we’ll let Abaqus do the heavy lifting — it will write the script for you.
Then you’ll read it, understand it, and modify it.
Let’s do this together in four simple steps:
Step 1: Three Ways to Get the Script of Your Model
When you work in Abaqus/CAE, your actions are recorded automatically in different files:
- Replay file (abaqus.rpy): Records every GUI action in Python commands. Good for reproducing your exact steps.
- Macro file (macro.py): If you start recording a macro (File → Macro Manager → Record), Abaqus will save your steps into a script you name yourself.
- Journal file (.jnl): Created when you save a model. It contains a Python-based record of the session, focusing on commands needed to recreate the saved state.
Any of these files can be a starting point for learning Abaqus Python scripting.
Step 2 Open the File and See the Real Code
# -*- coding: mbcs -*-
#
# Abaqus/CAE Release 2024 replay file
# Internal use only
#
from abaqus import *
from abaqusConstants import *
import __main__
Mdb()
mdb.models[‘Model-1′] = mdb.Model(name=’Model-1’, modelType=STANDARD_EXPLICIT)
mdb.models[‘Model-1′].ConstrainedSketch(name=’__profile__’, sheetSize=200.0)
mdb.models[‘Model-1’].sketches[‘__profile__’].rectangle(point1=(0.0, 0.0), point2=(10.0, 10.0))
mdb.models[‘Model-1′].Part(dimensionality=THREE_D, name=’Block’, type=DEFORMABLE_BODY)
mdb.models[‘Model-1’].parts[‘Block’].BaseSolidExtrude(depth=5.0, sketch=mdb.models[‘Model-1’].sketches[‘__profile__’])
from abaqus import *
from abaqusConstants import *
# Create a new model
mdb.models[‘Model-1′] = mdb.Model(name=’Model-1’)
# Create a sketch and draw a rectangle
s = mdb.models[‘Model-1′].ConstrainedSketch(name=’__profile__’, sheetSize=200.0)
s.rectangle(point1=(0.0, 0.0), point2=(10.0, 10.0))
# Create a 3D part from the sketch
p = mdb.models[‘Model-1′].Part(name=’Block’, dimensionality=THREE_D, type=DEFORMABLE_BODY)
p.BaseSolidExtrude(sketch=s, depth=5.0)
Step 3 Learn by Mathing
Create another shape in the GUI, then look at the macro/replay file again.
You’ll see how Abaqus turned your clicks into Abaqus Scripting commands.
Do this a few times, and you’ll start recognizing patterns.
Step 4 Modify the Script
Now, make a small change in our example; let’s say we change the rectangle size from (0,0) to (10,10)
to (0,0) to (20,15).
The left code is the orginal with changes we made and right one we prepared for your understanding.
from abaqus import *
from abaqusConstants import *
# Create a new model
mdb.models[‘Model-1′] = mdb.Model(name=’Model-1’)
# Create a sketch and draw a bigger rectangle
s = mdb.models[‘Model-1′].ConstrainedSketch(name=’__profile__’, sheetSize=200.0)
s.rectangle(point1=(0.0, 0.0), point2=(20.0, 15.0)) # Changed size
# Create a 3D part with more depth
p = mdb.models[‘Model-1′].Part(name=’Block’, dimensionality=THREE_D, type=DEFORMABLE_BODY)
p.BaseSolidExtrude(sketch=s, depth=8.0) # Changed depth
Lesson 5: How to Run Your Abaqus Python Script
Now that you have your first script, it’s time to run it.
There are two main ways to do this.
Each method has pros and cons.
Method 1: Run from Abaqus/CAE
- Open Abaqus/CAE.
- Go to the menu → File → Run Script → choose block_modified.py. (block_modified is your file’s name)
Advantages:
- Easy for beginners.
- You can see the model update right away in the GUI.
Disadvantages:
- Slower for large models.
- You must have the CAE interface open.
Method 2: Run from the System Command Line (cmd)
- Save the script as block_script.py in your working directory.
- Open Command Prompt (Windows: Press Windows + R, type cmd, and hit Enter.) or terminal (Linux/Mac).
- Navigate to the script folder with this command: cd “C:\Users\CAE Assistant Group\Desktop\New folder” (in the quotes paste your file’s path)
- Run the script in Abaqus without the GUI with this command: abaqus cae noGUI=block_script.py
Advantages:
- Faster for large scripts.
- You can run scripts without opening the GUI.
- Useful for automation and batch processing.
Disadvantages:
- Less visual feedback.
- Harder for absolute beginners to debug.
Recap: What You’ve Learned
In this beginner-friendly journey into Abaqus Python scripting, you’ve covered everything you need to start automating and customizing your work in Abaqus.
Here’s what we explored together:
- Lesson 1 – What Abaqus scripting is, how Python connects with Abaqus, and real-world uses like 3D printing automation, plugin creation, and workflow customization.
- Lesson 2 – Python basics for Abaqus: variables, numbers, strings, lists, dictionaries, indentation, and simple examples.
- Lesson 3 – Key Abaqus terminology, the role of Python scripting in Abaqus, and important related files (.rpy, .jnl, macro files).
- Lesson 4 – How to use Abaqus-generated scripts as learning tools: recording models, reading and understanding the code, cleaning it up, making changes, and reusing it.
- Lesson 5 – Running your scripts in Abaqus/CAE and from the system command line — with exact copy-paste commands that work right away.
Final Challenge Exercise
To cement your skills:
- Create a simple model in Abaqus (like a block with an extrusion).
- Save the script in .rpy, .jnl, or macro.py format.
- Read through the file and identify each section of code.
- Modify at least one parameter (like dimensions, material, or step).
- Run your updated script from both Abaqus/CAE and the system command line.
- Observe the results and confirm your changes worked.
You’ve now taken your first real steps into the world of Abaqus Python scripting. From understanding the basics to running your own scripts, you’ve built a solid foundation to start automating and customizing your simulations. This is just the beginning — in our full tutorial package, we’ll explore advanced scripting techniques, optimization workflows, and custom GUI tools that will push your Abaqus skills to a whole new level. Keep experimenting, stay curious, and remember: the more you script, the more Abaqus works for you.
You can get all in our Abaqus Python Course.
The CAE Assistant is committed to addressing all your CAE needs, and your feedback greatly assists us in achieving this goal. If you have any questions or encounter complications, please feel free to share it with us through our social media accounts including WhatsApp.
You can always learn more about Abaqus in Abaqus Documentation.
Explore our comprehensive Abaqus tutorial page, featuring free PDF guides and detailed videos for all skill levels. Discover both free and premium packages, along with essential information to master Abaqus efficiently. Start your journey with our Abaqus tutorial now!
