SoaringFrank
Structural
- Nov 2, 2014
- 2
Hi there,
I thought you might find this particular set of scripts helpful.
The repeating task of exporting data for postprocessing in e.g. Excel might get dull over time.
So I wrote a couple of plugin skripts to automate that the export of all history outputs into textfiles.
The first script hooks into the abaqus plugin api and injects the pluginmenu button (buttonText='Export ODB History Output Repests')
into the abaqus cae "plugins" menu and links it to the second script which does the acutal work.
Save both scripts into your abaqus working directory into the folder 'abaqus_plugins' using the name 'exporter_plugin.py' for the
following script.
Save the second script into the same folder using the name 'exporter_main.py'.
For reasons of convenience I added those files as attachment to this post.
Have fun!
I thought you might find this particular set of scripts helpful.
The repeating task of exporting data for postprocessing in e.g. Excel might get dull over time.
So I wrote a couple of plugin skripts to automate that the export of all history outputs into textfiles.
The first script hooks into the abaqus plugin api and injects the pluginmenu button (buttonText='Export ODB History Output Repests')
into the abaqus cae "plugins" menu and links it to the second script which does the acutal work.
Save both scripts into your abaqus working directory into the folder 'abaqus_plugins' using the name 'exporter_plugin.py' for the
following script.
Python:
__author__ = 'SoaringFrank'
from abaqusGui import getAFXApp, Activator, AFXMode
from abaqusConstants import ALL
import os
thisPath = os.path.abspath(__file__)
thisDir = os.path.dirname(thisPath)
toolset = getAFXApp().getAFXMainWindow().getPluginToolset()
toolset.registerKernelMenuButton(
buttonText='Export ODB History Output Repests',
moduleName='exporter_main', functionName='exporter_main()' )
Save the second script into the same folder using the name 'exporter_main.py'.
Python:
__author__ = 'SoaringFrank'
from abaqus import *
from abaqusConstants import *
def exporter_main():
if len(session.odbs.keys()) == 0:
print 'ProstProcessing: Warning! There is no open ODB File in this session. Please open one or many ODB Files and try again.\n'
for (index, (full_name, db)) in enumerate(session.odbs.items()):
# Strip Full Path FileName
(path, separator, file_name) = full_name.rpartition('/')
file_name_no_extension = file_name.partition('.')[0]
export_file_name_no_extension = '/'.join([path, file_name_no_extension])
last_step = db.steps[db.steps.keys()[-1]]
print 'ProstProcessing: Exporting data from ODB File: Element {0} of {1} to folder: ""{2}"" - ODB-FileName: {3}\n'.format(
index+1,
len(session.odbs.keys()),
path,
file_name
)
write_history_output_requests_into_text_files(
abq_history_regions=last_step.historyRegions,
job_name=export_file_name_no_extension,
decimal_separator=','
)
if len(session.odbs.keys()) > 0:
print 'ProstProcessing: Done.\n'
## Writes the history output into a job specific text files for postprocessing with excel.
#
# Writes the following history data fields into different tabulator separated text files.
# Every history output request will result in a single text file.
# Each field inside a history output request will result in a column inside the corresponding file.
def write_history_output_requests_into_text_files(abq_history_regions, job_name, decimal_separator):
for region_key, abq_history_region in abq_history_regions.items():
history_keys = abq_history_region.historyOutputs.keys()
file_name = '{0}_{1}.txt'.format(job_name, "-".join(history_keys))
if len(history_keys)<1:
continue
with open(file_name, "w") as data_file:
data_file.write('Increment\t{0}\n'.format('\t'.join(history_keys)))
for line_index, increment in enumerate(abq_history_region.historyOutputs[history_keys[0]].data):
data_line = list()
data_line.append('{0:20.14f}'.format(increment[0]))
for history_key in history_keys:
data_line.append('{0:20.14f}'.format(abq_history_region.historyOutputs[history_key].data[line_index][1]))
data_file.write('{0}\n'.format('\t'.join(data_line)).replace('.', decimal_separator))
For reasons of convenience I added those files as attachment to this post.
Have fun!