示例代码见文末,功能室自动化保存每一帧的Mises应力云图。
在Abaqus/CAE中截图的时候有一些参数可选,在使用脚本截图的时候这些参数在printOptions中,可以调用函数
session.printOptions.setValues()
来设置。比如要取消保存的截图上的标题栏,可以将参数vpDecorations置为OFF。
保存的截图的效果如下图所示:
from abaqus import *
from abaqusConstants import *
import visualization
def PrintAllFrameToFile(odb_file, field_val, field_val_2):
myViewport = session.Viewport(name='Superposition example',
origin=(100, -10), width=200, height=150, border = ON)
myViewport.view.setViewpoint(viewVector=(1, 1, 1),
cameraUpVector=(1, 3, 6))
myOdb = visualization.openOdb(path=odb_file)
myViewport.setValues(displayedObject=myOdb)
step = myOdb.steps['Step-1']
for i in range(len(step.frames)):
frame = step.frames[i]
stress = frame.fieldOutputs[field_val]
myViewport.odbDisplay.setPrimaryVariable(field = stress,
utputPosition = INTEGRATION_POINT, refinement = (INVARIANT, field_val_2))
myViewport.odbDisplay.display.setValues(plotState = (CONTOURS_ON_DEF,))
myViewport.odbDisplay.commonOptions.setValues(renderStyle=FILLED)
session.printOptions.setValues(rendition = COLOR, compass = ON, vpDecorations = OFF)
session.printToFile(fileName = 'Mises_' + str(i), format = PN,canvasObjects = (myViewport,))
odb_file = 'Beam.odb'
field_val = 'S'
field_val_2 = 'Mises'
data = PrintAllFrameToFile(odb_file, field_val, field_val_2)
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删