One of the most powerful features of Abaqus is that the GUI is essentially a command generator for python, which is itself a very powerful open source scripting language. Any action that you take in Abaqus CAE is recorded as a python script and these scripts are available to you to modify and execute at any time. This enables you to do things like running automated parametric design studies, and when you combine the capabilities of Abaqus with the freely available python tools for optimization and other scientific tasks you can really start to take advantage of this tremendously powerful design tool. The basics of Abaqus scripting will be covered in a later post, in this post I’ll cover how to create a simple macro and add it to the GUI as a command button.
I’ve always been agitated by the fact that I have to manually refine the display of all parts in Abaqus, which seems to assume you are using a graphics card from the decade before last or dealing with extremely large parts. So, a macro to update the refinement for all of the open parts is something I have always thought would be useful. The macro that I created is sho
wn in the image below, and I will review line-by-line what the script is doing.
First, line 1 imports the abaqusConstants module so that its contents can be used. This script is ultimately going to be executed in python so when we reference the abaqusConstants module we get access to everything in Abaqus (like the parts and the models). Line 2 is a comment, denoted by the pound sign in python. Line 3 is a for next loop, and it will loop through all the models that are currently open. Line 4 is another for next loop, and this one loops through all of the parts in each of those models. Line 5 is where the refinement variable is set, and in this case I’m changing the value to FINE (although you could just as easily set it to superFINE). Line 7 is another change I always like to make when I start CAE, which is to switch the display from perspective to parallel. Alternatively it is now possible to make that change in your Abaqus preferences.
Once you have this file, which can be created by typing the text above into a text editor and saving it with a “.py” extension, you need to copy the contents into a modules file for Abaqus.
The only difference between this and the original script is that the code is now encapsulated in a function, SetDisplayProps in line 6. Now you will need to create a plugin file to reference and execute this command, and this is shown in the image below.
I will leave it to the user who wants to master scripting and plugin creation to figure out the exact function of this file, since it is not really relevant to this simple case. Even without that understanding, anyone can make their own plugins that call a script by using this as a template. Once you’ve created the myCAE_plugin.py file as above it needs to be saved in your Abaqus working directory (usually “C:\temp\”). Before you can use the plugin it will need to be compiled, and to do that execute the commands below from the python command line within Abaqus CAE:
This will give you .pyc files, and these need to be moved to your plugins folder – typically “abaqus_plugins” in the Abaqus installation folder (i.e. “C:\SIMULIA\Abaqus\6.14-2\abaqus_plugins\”). Now, restart Abaqus and you will see that the refinement plugin is available from the tool bar:
Once you have the plugin available you can create a button to execute it by clicking Tools -> Customize and then clicking the Create Toolbar button. From the window that comes up select the Functions tab and click on Plug-ins in the frame on the left and highlight your new plugin on the right. Add a keyboard shortcut if desired, select an icon and you now have access to this very useful command in Abaqus with just a single click.
I hope you have learned something from this post, if you would like to obtain the files we would be glad to provide them free of charge.