Sketches are one of the most important features in Abaqus. We need to use them during the preprocess of the geometry of our FE models: to create parts (extrusion, revolution, sweeping…), to make partitions and cuts, etc. Therefore, to take advantage of the automation capabilities of Abaqus by means of Python scripts, we need to know how to generate these sketches using Python commands.
1. The first sketch with a Python script
Let’s start by creating some basic geometrical features in a sketch and later we will construct the parametric curve (spiral) shown in the image below, through a Python script. This sort of geometry would be unfeasible to make by hand in Abaqus/CAE, probably we would need to draw it somewhere else and import it, but thanks to Python scripting we can directly have it right into Abaqus!
The spiral is defined by the following parametric curve:
$$0 \leq \theta \leq 2 \pi N$$
$$r(\theta) = r_0 + (r_f-r_0) \cdot \frac{\theta}{2 \pi N}$$
Where \(N\) is the number of loops of the spiral, \(r_0\) is the inner radius, and \(r_f\) is the outer radius of the spiral.
Cartesian coordinates are obtained by projecting \(r\) along the (x, y) axes:
$$x = r \cdot \cos \theta$$
$$y = r \cdot \sin \theta$$
Download here the script to generate the sketch of the spiral shown in the video above.
2. Moving on using sketches with Abaqus Scripting
We can take our spiral way further by understanding a few key concepts about sketches in Abaqus. For instance, the 2 main objects required by any sketch are vertices and geometry.
Let’s smooth out our spiral using splines and then mirror it to obtain a double antisymmetric spiral.
And all this will be implemented in a Python script such that we can obtain our sketch automatically in Abaqus/CAE!
Download the script to generate the sketch of the double spiral shown in the video.
3. Debugging Python commands in our sketches
Very often we run into the same situation:
“I want to test my Python commands within Abaqus/CAE to check how it works, but I cannot!”
You’re right, when we open an existing or a new sketch and try to run our Python commands from the Command Line Interface, we may get some unexpected behaviour in most cases.
This happens because Abaqus employs temporary sketches before we complete them in CAE (“Done“):
- __edit__: this sketch is created when we open an existing sketch.
- __profile__: this one is generated when we create a new sketch.
In the next video, we will explain how these “__edit__” and “__profile__” sketches are created by Abaqus/CAE and how to use them to avoid all sort of errors and weird behaviour of sketches while testing and debugging Python commands.
Download the script to generate the sketch of the double spiral shown at the beginning of the video (watch the video of part 2 for all the details). And of course, if you have any question/suggestion/opinion leave it in the comments section below.
You can also get started in Abaqus/Scripting with Python in this post. This is the starting point to learn how to create your own Python scripts from scratch.
I hope that you find these tips useful!