打开 Odb 并显示等值线图

viewerOpenOdbAndContour.py 来自于 Opening an output database and displaying a contour plot.

将等值线图打印到本地 PNG 格式文件中。

在运行此脚本之前运行以下命令:

abaqus fetch job=viewer_tutorial

下面是一个包含 Abaqus 脚本接口命令的脚本示例,其中使用了 Viewing the Output from Your Analysis 所使用的输出数据库。

使用以下命令获取示例脚本:

abaqus fetch job=viewerOpenOdbAndContour

该脚本执行以下操作:

  • 创建一个视图,并使其成为当前视图。

  • 打开输出数据库。

  • 显示等值线图。

  • 显示第三步第一帧的模型。

  • 设置等值线间隔数和等值线限值。

  • 将视图的彩色图像打印成 .png 文件。

import visualization
from abaqus import *
from abaqusConstants import *

# Create a new Viewport for this example.

myViewport = session.Viewport(name="Print a contour plot", origin=(10, 10), width=200, height=100)

# Open the output database and associate it
# with the new viewport.

odbPath = "viewer_tutorial.odb"
myOdb = visualization.openOdb(path=odbPath)

myViewport.setValues(displayedObject=myOdb)


# Display a contour plot of the output database.

myViewport.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))

# Change to the first frame of the third step.
# Remember that indices in Python begin with zero:
#   The index of the first frame is 0.
#   The index of the third step is 2.

myViewport.odbDisplay.setFrame(step=2, frame=0)

# Change the number of contour intervals to 10
# starting at 0.0 and ending at 0.10.

myViewport.odbDisplay.contourOptions.setValues(
    numIntervals=10,
    maxAutoCompute=OFF,
    maxValue=0.10,
    minAutoCompute=OFF,
    minValue=0.0,
)

# Generate color output.
# Do not print the viewport decorations or the black background.

session.printOptions.setValues(rendition=COLOR, vpDecorations=OFF, vpBackground=OFF)

# Print the viewport to a local PNG-format file.

session.printToFile(fileName="contourPlot", format=PNG, canvasObjects=(myViewport,))

Sphinx-Gallery 生成