-
Notifications
You must be signed in to change notification settings - Fork 2
/
screen_shot_script.py
99 lines (95 loc) · 4.62 KB
/
screen_shot_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#%% For the paper
from abaqus import *
from abaqusConstants import *
# Load output library
o1 = session.openOdb(
name='X:/YuxiangWang/AbaqusFolder/YoshiModel/odbs/SkinAlpha22Displ.odb')
session.viewports['Viewport: 1'].setValues(displayedObject=o1)
session.viewports['Viewport: 1'].odbDisplay.display.setValues(plotState=(
CONTOURS_ON_DEF, ))
# Set screen location
session.viewports['Viewport: 1'].view.setValues(nearPlane=0.0377807,
farPlane=0.0545155, width=0.00143955, height=0.00159838,
viewOffsetX=-0.00363814, viewOffsetY=0.00325194)
# Set details
session.viewports['Viewport: 1'].viewportAnnotationOptions.setValues(
compass=OFF, title=OFF, state=OFF, annotations=OFF, legendBox=OFF,
legendNumberFormat=FIXED)
# Setting contour and edge colors here
color_list = []
for i in range(16):
color_list.append('#%sFF' % (hex(15-i)[-1]*4))
for i in range(15):
color_list.append('#0000%s' % (hex(14-i)[-1]*2))
# session.Spectrum(name="Blue", colors = tuple(['#%sFF' % (hex(i)[-1]*4) for i in range(15)]))
session.Spectrum(name="Blue", colors = tuple(color_list[::-1]))
session.viewports['Viewport: 1'].odbDisplay.contourOptions.setValues(
spectrum='Blue', numIntervals=12)
session.viewports['Viewport: 1'].odbDisplay.setPrimaryVariable(
variableLabel='S', outputPosition=INTEGRATION_POINT, refinement=(INVARIANT,
'Min. Principal'), )
# Save eps
session.epsOptions.setValues(fontType=PS_ALWAYS, shadingQuality=EXTRA_FINE)
session.printToFile(
fileName='X:/YuxiangWang/AbaqusFolder/YoshiModel/figures/screenshot.eps',
format=EPS, canvasObjects=(session.viewports['Viewport: 1'], ))
# Save png
session.pngOptions.setValues(imageSize=(3000, 3337))
session.printOptions.setValues(reduceColors=False)
session.printToFile(
fileName='X:/YuxiangWang/AbaqusFolder/YoshiModel/figures/screenshoot',
format=PNG, canvasObjects=(session.viewports['Viewport: 1'], ))
# Zoom in and save png again
session.viewports['Viewport: 1'].view.setValues(nearPlane=0.0380141,
farPlane=0.0542822, width=0.000147796, height=0.0001,
viewOffsetX=-0.00408086, viewOffsetY=0.00355891)
session.pngOptions.setValues(imageSize=(3000, 3337))
session.printOptions.setValues(reduceColors=False)
session.printToFile(
fileName='X:/YuxiangWang/AbaqusFolder/YoshiModel/figures/screenshoot_zoomed_in',
format=PNG, canvasObjects=(session.viewports['Viewport: 1'], ))
session.printToFile(
fileName='X:/YuxiangWang/AbaqusFolder/YoshiModel/figures/screenshot_zoomed_in',
format=EPS, canvasObjects=(session.viewports['Viewport: 1'], ))
#%% For understanding stress distribution
from abaqus import *
from abaqusConstants import *
def screenshot(jobName):
# Load output library
o1 = session.openOdb(
name='X:/YuxiangWang/AbaqusFolder/YoshiModel/odbs/%s.odb' % jobName)
session.viewports['Viewport: 1'].setValues(displayedObject=o1)
session.viewports['Viewport: 1'].odbDisplay.display.setValues(plotState=(
CONTOURS_ON_DEF, ))
# Set screen location
session.viewports['Viewport: 1'].view.setValues(nearPlane=0.0377807,
farPlane=0.0545155, width=0.00143955, height=0.00159838,
viewOffsetX=-0.00363814, viewOffsetY=0.00325194)
# Set details
session.viewports['Viewport: 1'].viewportAnnotationOptions.setValues(
compass=OFF, title=OFF, state=OFF, annotations=OFF, legendBox=OFF,
legendNumberFormat=FIXED)
session.viewports['Viewport: 1'].odbDisplay.contourOptions.setValues(
contourStyle=CONTINUOUS, spectrum='Reversed rainbow')
session.viewports['Viewport: 1'].odbDisplay.setPrimaryVariable(
variableLabel='S', outputPosition=INTEGRATION_POINT, refinement=(INVARIANT,
'Min. Principal'), )
# Save png
session.pngOptions.setValues(imageSize=(3000, 3337))
session.printOptions.setValues(reduceColors=False)
session.printToFile(
fileName='X:/YuxiangWang/AbaqusFolder/YoshiModel/figures/screenshoot'+jobName,
format=PNG, canvasObjects=(session.viewports['Viewport: 1'], ))
# Zoom in and save png again
session.viewports['Viewport: 1'].view.setValues(nearPlane=0.0380141,
farPlane=0.0542822, width=0.000147796, height=0.0001,
viewOffsetX=-0.00408086, viewOffsetY=0.00355891)
session.pngOptions.setValues(imageSize=(3000, 3337))
session.printOptions.setValues(reduceColors=False)
session.printToFile(
fileName='X:/YuxiangWang/AbaqusFolder/YoshiModel/figures/screenshoot_zoomed_in'+jobName,
format=PNG, canvasObjects=(session.viewports['Viewport: 1'], ))
return
jobNameList = ['SkinThick%d2Force' % i for i in range(5)]
for jobName in jobNameList:
screenshot(jobName)