The example script

This example shows how you can use an Abaqus/CAE script to replicate the functionality of Abaqus/CAE.

The script does the following:

  • Creates a new model in the model database.

  • Creates a two-dimensional sketch.

  • Creates a three-dimensional, deformable part.

  • Extrudes the two-dimensional sketch to create the first geometric feature of the part.

  • Creates a new viewport.

  • Displays a shaded image of the new part in the new viewport.

The new viewport and the shaded part are shown in Figure 1.

Figure 1. The example creates a new viewport and a part.

The example scripts from this guide can be copied to the user's working directory by using the Abaqus fetch utility:

abaqus fetch job=scriptName

where scriptName.py is the name of the script (see Fetching sample input files). Use the following command to retrieve the script for this example:

abaqus fetch job=modelAExample

Note: Abaqus does not install the sample scripts by default during the installation procedure. As a result, if the Abaqus fetch utility fails to find the sample script, the script may be missing from your Abaqus installation. You must rerun the installation procedure and request Abaqus sample problems from the list of items to install.

To run the program, do the following:

  1. Start Abaqus/CAE by typing abaqus cae.

  2. From the startup screen, select Run Script.

  3. From the Run Script dialog box that appears, select modelAExample.py.

  4. Click OK to run the script.

Note: If Abaqus/CAE is already running, you can run the script by selecting FileRun Script from the main menu bar.

The example follows:

"""
modelAExample.py

A simple example: Creating a part.
"""

from abaqus import *
from abaqusConstants import *
backwardCompatibility.setValues(includeDeprecated=True,
                                reportDeprecated=False)

import sketch
import part

myModel = mdb.Model(name='Model A')

mySketch = myModel.ConstrainedSketch(name='Sketch A',
                                     sheetSize=200.0)

xyCoordsInner = ((-5 , 20), (5, 20), (15, 0),
    (-15, 0), (-5, 20))

xyCoordsOuter = ((-10, 30), (10, 30), (40, -30),
    (30, -30), (20, -10), (-20, -10),
    (-30, -30), (-40, -30), (-10, 30))

for i in range(len(xyCoordsInner)-1):
    mySketch.Line(point1=xyCoordsInner[i],
        point2=xyCoordsInner[i+1])

for i in range(len(xyCoordsOuter)-1):
    mySketch.Line(point1=xyCoordsOuter[i],
        point2=xyCoordsOuter[i+1])

myPart = myModel.Part(name='Part A', dimensionality=THREE_D,
    type=DEFORMABLE_BODY)

myPart.BaseSolidExtrude(sketch=mySketch, depth=20.0)

myViewport = session.Viewport(name='Viewport for Model A',
    origin=(10, 10), width=150, height=100)

myViewport.setValues(displayedObject=myPart)

myViewport.partDisplay.setValues(renderStyle=SHADED)