PeterHughes
Materials
- Feb 22, 2009
- 2
Good Afternoon
I'm new to scripting, or any sort of programming and am trying to write a script to extract the displacements and load from a set of nodes in an Abaqus OBD file, as I have about 1000 files to extract data from. I have searched Google/these forums but haven't yet found a solution.
I have managed through adapting the .rpy file and guess work/Google/books to get to the stage where I can open my files, and read them however rather than print the data from 1.odb, 2.odb, 3.odb etc, it just prints the data from one of the files three times. I have included a line that prints the name of the file, and it appears to open all the files in the directory but just not output the correct data.
I would be very grateful if someone with Python/Abaqus experience could have a look and tell me where I have gone wrong and how to remedy this. I have tried changing the indentation to see if that helps, but to no avail.
The file is attached, and runs fine (excluding above error) though File>Run Script in 6.7 however doesn't like being run in command line.
Any input greatly appreciated.
I'm new to scripting, or any sort of programming and am trying to write a script to extract the displacements and load from a set of nodes in an Abaqus OBD file, as I have about 1000 files to extract data from. I have searched Google/these forums but haven't yet found a solution.
I have managed through adapting the .rpy file and guess work/Google/books to get to the stage where I can open my files, and read them however rather than print the data from 1.odb, 2.odb, 3.odb etc, it just prints the data from one of the files three times. I have included a line that prints the name of the file, and it appears to open all the files in the directory but just not output the correct data.
I would be very grateful if someone with Python/Abaqus experience could have a look and tell me where I have gone wrong and how to remedy this. I have tried changing the indentation to see if that helps, but to no avail.
The file is attached, and runs fine (excluding above error) though File>Run Script in 6.7 however doesn't like being run in command line.
Any input greatly appreciated.
Code:
### import required modules
import sys, os
from abaqus import *
from abaqusConstants import *
from caeModules import *
from driverUtils import executeOnCaeStartup
#
### point it at the files:
#
FOLDER = '/home/myfolder'
#
os.chdir(FOLDER)
for filename in os.listdir('.'):
#
#
#f = open('/home/files.txt','a')
#print >>f, filename
### open abaqus module
#
executeOnCaeStartup()
Mdb()
### open file, set view
o1 = session.openOdb(
name=filename)
session.viewports['Viewport: 1'].setValues(displayedObject=o1)
session.viewports['Viewport: 1'].view.setValues(nearPlane=43.3078,
farPlane=76.6444, width=38.4285, height=19.2364, cameraPosition=(-22.5167,
5.17008, 48.8967), cameraUpVector=(-0.602818, -0.140808, -0.785356))
odb = session.odbs[filename]
### extract reaction force
session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=(('RF',
NODAL, ((COMPONENT, 'RF2'), )), ), nodeSets=('LOADY', ))
### extract displacements
odb = session.odbs[filename]
session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=(('U',
NODAL, ((COMPONENT, 'U1'), )), ), nodeSets=('XEXPPOS-VERT', ))
odb = session.odbs[filename]
session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=(('U',
NODAL, ((COMPONENT, 'U3'), )), ), nodeSets=('Z-EXPPOS-TRANS', ))
### assign data to variable
x0 = session.xyDataObjects['RF:RF2 PI: BCC_FCC-1 N: 8']
x1 = session.xyDataObjects['U:U1 PI: BCC_FCC-1 N: 14']
x2 = session.xyDataObjects['U:U1 PI: BCC_FCC-1 N: 17']
x3 = session.xyDataObjects['U:U1 PI: BCC_FCC-1 N: 23']
x4 = session.xyDataObjects['U:U1 PI: BCC_FCC-1 N: 25']
x5 = session.xyDataObjects['U:U3 PI: BCC_FCC-1 N: 16']
### report data
session.xyReportOptions.setValues(minMax=ON)
session.writeXYReport(
fileName='/home/data.rpt',
xyData=(x0, x1, x2, x3, x4, x5))