Python script to get ODB object

Python script could also be used to perform postprocessing in Abaqus. The first step might be to get the ODB object containing the data to process. Here are two methods to create a variable for the ODB object.

From current viewport

This might be the most convenient way to assign an ODB object to a variable. Manual operation, however, is required before this could work.

So the first step is to navigate to the desired ODB in current viewport in Abaqus, which means we must “see” the result of the desired model in current work space. Yes, the odb file is already opened in Abaqus just in front of us.

Now the following script will get something from current viewport.

from abaqus import session

# get the current viewport
currentViewport = session.viewports[session.currentViewportName]
# get odb object from current viewport
odb = currentViewport.displayedObject

This should be enough for ordinary data process, such as plot the velocity in History Output,

xy0 = xyPlot.XYDataFromHistory(odb=odb, 
 outputVariableName='Spatial velocity: V1', 

But we could do more for labelling,

# get odb file path with name
odbNameFull = odb.path
# split into separately path and name
odbPath = os.path.split(odbNameFull)[0]
odbName = os.path.split(odbNameFull)[1]

From file

We can also open an ODB and process it all in script. But we must know exactly the path and name of the ODB file. For example,


Here is the script for using this ODB file as object,

# the path and name
odbNameFull = "C:\Works\example-model.odb"
# open and assign this odb object to a variable 
odb = openOdb(path = odbNameFull)

If you have something about this, please leave a comment below to share with us.©



电子邮件地址不会被公开。 必填项已用*标注

您可以在评论中使用如下的 HTML 标记来辅助表达: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>