A few weeks back, I was made aware of a bug in release 6.14-1. The description of the bug was as follows:
In Abaqus/CAE, trying to copy and paste in certain tables can cause the Windows clipboard to not function
It turns out that this is very inconvenient if you use third-party software such as excel or similar to create graphs to do comparisons. This bug was luckily resolved quickly thereafter (in 6.14-2).
My first response was to quickly create a workaround in the form of a simple python script (included at the end of the post).
I knew that the XYdata was intended to be visualized in excel, so I tried a few ways to quickly create a graph.
I quickly learned that the outputted values should:
- have the same decimal separator marker as Excel (comma separated)
- be separated by a tab – so that Excel puts the values in different columns
The values are stored as “.txt” files with the same name as the XYdata in Abaqus/CAE and obeys the two rules above. I can easily copy/paste these values directly into Excel and click a button to get a graph.
So, if you often work with graphs in excel – you might find this script useful – see below to get it!
[sourcecode language=”python” wraplines=”false” collapse=”false”]
# exportXYdata.py 2014-10-13
# Ebbe Smith – PLM Technology AS
#———————————-
# Imports
#———————————-
from abaqus import *
from abaqusConstants import *
#———————————-
# Functions
#———————————
def main():
for xyDataKey in session.xyDataObjects.keys():
xyData = session.xyDataObjects[xyDataKey]
with open("%s.txt" % xyDataKey, ‘w’) as fp:
for line in xyData:
nline = "%ft%fn" % (line[0], line[1])
fp.write(nline.replace(‘.’, ‘,’))
#———————————-
#———————————-
# Entrypoint
#———————————-
if __name__ == ‘__main__’:
main()
[/sourcecode]
Thank you for your post. Actually I have the same problem of exporting datat from abaqus and your script can come up really handy. Could you please advise how can I use it? Is it executed inside the abaqus?
Hi Armin,
Yes, this script is executed inside abaqus. You can run it with “file->run script..” or “execfile(‘script.py’)” in the CLI (command line interface)
As is, the script formats the XYdata and write it to a simple text-file, with some additional scripting its possible to drop it to the windows clipboard, or even directly into excel.
That might be new post for another day 🙂
Hi Ebbe,
Thank you for this code snippet. I am also facing this problem of exporting data directly from Python script to Excel.
Actually I have only one XYData Object which has a sequence of X-Y data pairs. So could you help me with the code to export this Data to Excel. I will paste a part of my Code here :
=======================================
import sys
sys.path.insert(10,
r’c:/SIMULIA/Abaqus/6.13-4/code/python/lib/abaqus_plugins/excelUtilities’)
import abq_ExcelUtilities.excelUtilities
frames = myOdb.steps[‘SSD_Analysis’].frames
chg = 0.0
Capac = [ ]
for frame in frames:
subRchg = complexMagnitude(frame.fieldOutputs[‘RCHG’].getSubset(region = TopNodes,position=NODAL))
for val in subRchg.values :
chg = chg + val.data
Capac.append((chg/20.0,frame.frequency))
chg = 0
Chgxy = myOdb.userData.XYData(name = ‘Total Capac’,data= Capac)
abq_ExcelUtilities.excelUtilities.XYtoExcel(xyDataNames=’Total Capac’, trueName=”)
==================================================================
But I get the error that xyDataNames = ‘Total Capacity’ does not exist everytime. How can I resolve this ?
Second error is that I need to change the name of the XYdata object everytime I run the script , because it says ‘ Cannot overwrite the Object ‘Total Capacity’ ‘ .
Is it because the Object is getting saved to the Odb ?
Hi Ashish,
Yes! I mention the excelUtilities in https://www.plmtechnology.no/abaqus-export-data-to-excel-part-2/
The main problem is that XYData(name=’Total Capac’, data=Capac) does not exists the first time you run it, and the script runs perfectly (I guess). The next time,
the script be unable to create the XYdata and fail.
I would perhaps try to delete this xyDataObject before creating the data, and avoid using “User Data Objects” if it is acceptable to not store this data permanently to the ODB.
You are not allowed to remove information from the ODB, to maintain integrity of the results. (If you however know how to delete fieldOutputs or UserData directly from an ODB file – I am keen on learning how it can be done)
======================================
# try to delete exisiting XYdata sets from previous runs
try:
del session.xyDataObjects[‘Total Capac’]
except:
pass
# now we are sure that there is no conflicting xyDataObjects
xyData = session.XYData(name=’Total Capac’, data=Capac)
===========================================