Using Scripts to Provide Additional Pre- and Postprocessing Functionality

The Abaqus component executes two specific user-supplied Python modules, if they exist. These modules must be called userscript_cae_pre.py and userscript_cae_post.py. You can leverage these scripts to operate on parameters in the Abaqus/CAE model database that are not yet supported by the component or to perform other operations needed to produce the Abaqus input file.

The following topics are discussed:

You can define one, both, or neither of these modules. The Abaqus component executes the preprocessing module, userscript_cae_pre.py, after opening a reference copy of the Abaqus/CAE model database file. The postprocessing module, userscript_cae_post.py, is executed before the Abaqus component writes solver input file for all jobs defined in the Abaqus/CAE model database. For more information, see How the Component Interacts with Abaqus/CAE.

The call to the userscript_cae_pre.py module is as follows:

if os.path.exists('userscript_cae_pre.py'):
import userscript_cae_pre
userscript_cae_pre.runUserScript(mdb, values)

where mdb is the model database and values is a name:value array of inputs.

The call to the userscript_cae_post.py module is as follows:

if os.path.exists('userscript_cae_post.py'):
import userscript_cae_post
userscript_cae_post.runUserScript(mdb, values)

where mdb is the model database and values is a name:value array of inputs.

An Example of a Preprocessing User Script

You can execute a preprocessing user-supplied module called userscript_cae_pre.py. The Abaqus component executes the preprocessing module after opening a reference copy of the Abaqus/CAE model database file.

If the userscript_cae_pre.py or userscript_cae_post.py modules are present in the same directory as the Abaqus/CAE model database file at the time of the file scan, the component automatically generates file parameters to ensure that these scripts are copied to the execution directory at run time.

An example of userscript_cae_pre.py is shown below:

from abaqus import *
from abaqusConstants import *
import __main__
import section
import regionToolset
import displayGroupMdbToolset as dgm
import part
import material
import assembly
import step
import interaction
import load
import mesh
import job
import sketch
import visualization
import xyPlot
import displayGroupOdbToolset as dgo
import connectorBehavior

def runUserScript(mdb, values):
    models = mdb.models
    p = models['Model-1'].parts['Part-1']
    
p.features['Round-3'].setValues(radius=(float(values['Model_1__Part_1_
_Round_2__radius']) - 0.4))
    p.regenerate()

In this example preprocessing script the value of Round-3 is modified as a function of Round-2.