Skip to content

Customizing your Abaqus 2022 environment with Python

Posted by Ebbe Smith

Home > Blog > Customizing your Abaqus 2022 environment with Python

Table of contents

    Abaqus/CAE is integrated with Python 2.7, settings and commands are read through python-based environment files at start-up and commands are streamed to replay files along the session. This produces powerful opportunities to form the CAE environment into a specialized package to accelerate day-to-day tasks. Instead of painting a flowery picture I’d rather jump in and demonstrate selected techniques that enables you to customize the user interface to your will.

    I often work on organically shaped CAD data and often find the default geometrical refinement setting too low – this does sadly not exist in the session.default* objects so we need to apply some creative approaches.

    python-1

    Identification of the required snippet required to change the Geometrical Refinement Level is found by changing this parameter for a specific part in Abaqus/CAE and look at the Abaqus Reply File (RPY).

    python-2-a

    I want to make a script that changes the refinement level for all the parts in the model which is currently open. The required code can then be made accessible as a kernel script, kernel plugin or integrated in the environment to be run when specific functions are called.

    Kernel Script

    Kernel scripts are useful for developing scripts or running project specific code that requires limited accessibility. The required code block that loops over the parts in the model is fairly simple and requires the mandatory imports from Abaqus and abaqusConstants.

    GeometryRefinement.py:
    python-3

    This script can be run by “File->Run Script..” in Abaqus.

    python-4

    Registered Kernel Script

    Browsing for the script each time such a script is required is tedious. We can with a few more lines turn it into an accessible plugin within Abaqus/CAE by registering the script at start-up.

    GeometryRefinement_Register.py:

    python-5

    python-6

    On start-up, Abaqus 2022 scans for plugin in ”C:\SIMULIA\CAE\plugins\2022”. Create a folder called “Geometry Refinement” at this location and add GeometryRefinement.py and GeometryRefinement_plugin.py to make them available in Abaqus/CAE.

    Scripts_in_folder

    Environment File

    Both kernel script and registered plugin requires interaction to be launched. If you don’t work regularly on complex CAD data this functionality can be implemented as a callback function in the environment file.

    One of the most common functions in the environment files are “onCaeStartup()” which enables us to set some other defaults too. Most of these defaults can naturally be saved using “File->Save Display Options…”.

    Callback functions can be run before or after a specific command in Abaqus has been called. This means it’s possible to automatically get some code run at specific events!

    First we need to locate our environment file: “C:\SIMULIA\EstProducts\2022\win_b64\SMA\site\custom_v6.env”

    I have chosen to run the refinement procedure every time I create an instance or load a .cae file. By look at the reply file (.rpy) we find the function names “Instance()” and “openMdb()” – we can use methodCallback.addCallback to attach our snippet to these functions.

    Custom_v6.env:

    python-8

    Closing Remarks

    We have look at the three different techniques to run a simple function. Depending on the intended use one of these might be preferable. For example, if you are working on complex CAD geometry – having this snippet run unintentionally might actually cost you a few minutes or completely break melt your computer when importing huge assemblies. It’s better to decide when to run it for this example – but there are many other uses for using callbacks!

    Want to talk about scripting? Reach me at ebbe.smith@technia.com!

    Simulation Driven Innovation.

    TECHNIA Simulation provides top tier FEA, Non-linear, and Advanced Simulation Software, Training, and Consultancy. Our dedicated team of more than 65 Simulation experts across 16 countries advise and support your innovation with a wealth of specialist knowledge and experience.

    About TECHNIA
    Want to receive more content like this?
    • Related news and articles straight to your inbox
    • Hints, tips & how-tos
    • Thought leadership articles

    VISIT THE KNOWLEDGE HUB

    Helping you find the information you’re looking for. Discover webinars, events, FAQ's, case studies and tutorials.

    VIEW HUB
    © TECHNIA 2023 (Part of the Addnode Group) TECHNIA is certified according to ISO standards 9001:2015, 14001:2015 and 27001:2015 – Quality & Environment