备注
Go to the end to download the full example code.
打印等值线图¶
viewerPrintContours.py 来自于 Printing a contour plot at the end of each step.
将一组等值线图打印成 .png 文件。
在运行此脚本之前运行以下命令:
abaqus fetch job=viewer_tutorial
下面的示例脚本演示了如何在输出数据库文件的每个步骤的最后一帧生成并打印等值线图。该示例设置了适当的等值线限制,以便在固定范围内查看所有绘图。
使用以下命令获取示例脚本:
abaqus fetch job=viewerPrintContours
该脚本执行以下操作:
定义等值线限值函数。
确定输出数据库文件中每个分析步的最终帧。
在每一步的最后一帧绘制等值线图。
将等值线图打印到文件中。
import visualization
from abaqus import *
from abaqusConstants import *
# Create a viewport for this example.
myViewport = session.Viewport(name="Print contour plot after each step", origin=(10, 10), width=150, height=100)
# Open the output database and associate it with the viewport.
# Then set the plot state to CONTOURS_ON_DEF
try:
myOdb = visualization.openOdb(path="viewer_tutorial.odb")
except Exception as e:
print("Error:", e)
myViewport.setValues(displayedObject=myOdb)
myViewport.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
# Determine the number of steps in the output database.
mySteps = myOdb.steps
numSteps = len(mySteps)
# Set the maximum and minimum limits of the contour legend.
myViewport.odbDisplay.contourOptions.setValues(
numIntervals=10, maxAutoCompute=OFF, maxValue=0.1, minAutoCompute=OFF, minValue=0.0
)
# Establish print preferences.
session.printOptions.setValues(vpBackground=OFF)
session.psOptions.setValues(orientation=LANDSCAPE)
myViewport.viewportAnnotationOptions.setValues(triad=OFF, title=OFF, state=OFF)
myViewport.odbDisplay.basicOptions.setValues(
coordSystemDisplay=OFF,
)
# For each step, obtain the following:
# 1) The step key.
# 2) The number of frames in the step.
# 3) The increment number of the last frame in the step.
#
for i in range(numSteps):
stepKey = mySteps.keys()[i]
step = mySteps[stepKey]
numFrames = len(step.frames)
# Go to the last frame.
# Display a contour plot.
# Display the step description and the increment number.
myViewport.odbDisplay.setFrame(step=i, frame=numFrames - 1)
myViewport.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
# Remove white space from the step key and use the result
# to name the file.
fileName = stepKey.replace(" ", "")
# Print the viewport to a file.
session.printToFile(fileName, PNG, (myViewport,))
由 Sphinx-Gallery 生成